{"id":15097802,"url":"https://github.com/cristopher1/generator-koa2-simple-api-generator","last_synced_at":"2026-01-06T08:32:05.061Z","repository":{"id":232075730,"uuid":"782988997","full_name":"cristopher1/generator-koa2-simple-api-generator","owner":"cristopher1","description":"Yeoman generator to create a simple base structure for api rest based in koa2 framework.","archived":false,"fork":false,"pushed_at":"2024-04-07T20:51:44.000Z","size":253,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T17:44:44.154Z","etag":null,"topics":["api","base-structure","es6","eslint","husky","koa2","prettier","rest","yeoman-generator"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/generator-koa2-simple-api-generator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cristopher1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-06T16:13:41.000Z","updated_at":"2024-04-07T20:53:57.000Z","dependencies_parsed_at":"2024-04-07T20:42:45.613Z","dependency_job_id":"4c239d3c-e410-4164-9475-cdd62e133a99","html_url":"https://github.com/cristopher1/generator-koa2-simple-api-generator","commit_stats":{"total_commits":34,"total_committers":1,"mean_commits":34.0,"dds":0.0,"last_synced_commit":"444233ceb43a25862ffafcccb3449a76712ece47"},"previous_names":["cristopher1/generator-koa2-simple-api-generator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fgenerator-koa2-simple-api-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fgenerator-koa2-simple-api-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fgenerator-koa2-simple-api-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fgenerator-koa2-simple-api-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristopher1","download_url":"https://codeload.github.com/cristopher1/generator-koa2-simple-api-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245854330,"owners_count":20683335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","base-structure","es6","eslint","husky","koa2","prettier","rest","yeoman-generator"],"created_at":"2024-09-25T16:40:32.328Z","updated_at":"2026-01-06T08:32:00.042Z","avatar_url":"https://github.com/cristopher1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eWelcome to generator-koa2-simple-api-generator 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000\" /\u003e\n  \u003ca href=\"https://github.com/cristopher1/generator-koa2-simple-api-generator#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cristopher1/generator-koa2-simple-api-generator/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cristopher1/generator-koa2-simple-api-generator/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/cristopher1/generator-koa2-simple-api-generator\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Yeoman generator to create a simple base structure for api rest based in koa2 framework.\n\n### 🏠 [Homepage](https://github.com/cristopher1/generator-koa2-simple-api-generator)\n\nThis generator was created using [generator-esmodules-generator](https://www.npmjs.com/package/generator-esmodules-generator) version 1.0.3\n\nIf you want to use a tool with more settings, see [generator-koa2-api-generator](https://github.com/cristopher1/generator-koa2-api-generator)\n\n### What's changed? See [generator-koa2-simple-api-generator releases](https://github.com/cristopher1/generator-koa2-simple-api-generator/releases)\n\nExample of a generator created by `generator-koa2-simple-api-generator`:\n\n![generator-koa2-simple-api-generator-example](https://github.com/cristopher1/generator-koa2-simple-api-generator/assets/21159930/3d8ef769-5180-4419-bf3c-c441e9413744)\n\n### [Index](#index)\n\n- [Installation](#installation)\n- [Prerequisites](#prerequisites)\n- [Arguments and options](#arguments-and-options)\n- [Project structure](#structure)\n- [Generators included](#generators-included)\n- [The question: Do you want to automatically run the scripts that configure the package, then installing the dependencies?](#configuring-the-project-automatically)\n- [The scripts in package.json](#scripts)\n- [Getting To Know Yeoman](#know-yeoman)\n- [Author](#author)\n- [Contributing](#contributing)\n- [Show your support](#support)\n- [License](#license)\n\n## \u003ca id=\"installation\"\u003e\u003c/a\u003e Installation\n\nFirst, install [Yeoman](http://yeoman.io) and generator-koa2-simple-api-generator using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).\n\n```bash\nnpm install -g yo\nnpm install -g generator-koa2-simple-api-generator\n```\n\nThen generate your new project:\n\n```bash\nyo koa2-simple-api-generator project_name\n```\n\n## \u003ca id=\"prerequisites\"\u003e\u003c/a\u003e Prerequisites\n\nFirst, you must create a folder, then you enter it using the terminal. Finally you runs.\n\n```bash\nyo koa2-simple-api-generator project_name\n```\n\nExample:\n\n```console\nPS C:\\Users\\...\\new_koa2_api_project\u003e yo koa2-simple-api-generator project_name\n```\n\n## \u003ca id=\"arguments-and-options\"\u003e\u003c/a\u003e Arguments and options\n\nThe generator-koa2-simple-api-generator include one argument called **projectName**. **projectName** is a required argument:\n\nFor example: If you want to create a new koa2 api called koa2_api_project (projectName = koa2_api_project), you should use:\n\n```bash\nyo koa2-simple-api-generator koa2_api_project\n```\n\nThe generator-koa2-simple-api-generator include various options, these are:\n\n| option            |  value  | default | description                                                                                                            | example                                                                             |\n| :---------------- | :-----: | :-----: | :--------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |\n| runGitInit        | Boolean |  false  | Run git init automatically, then installing the dependencies                                                           | `yo koa2-simple-api-generator project_name --runGitInit`                            |\n| runPackageScripts | Boolean |  false  | Run the scripts that configure the package, then installing the dependencies                                           | `yo koa2-simple-api-generator project_name --runPackageScripts`                     |\n| useDocker         | Boolean |  false  | Add docker support using DockerFile, .dockerignore and others                                                          | `yo koa2-simple-api-generator project_name --useDocker`                             |\n| nodeVersion       | Number  |   16    | Node version used in DockerFile. (FROM nodeVersion). Recommended to use node 16, 18, 20 or 21                          | `yo koa2-simple-api-generator project_name --nodeVersion=21`                        |\n| projectFolderName | String  |   api   | Project folder name used in DockerFile. (WORKDIR /usr/src/projectFolderName)                                           | `yo koa2-simple-api-generator project_name --projectFolderName=project_folder_name` |\n| useDockerCompose  | String  |  false  | Add Docker Compose support.                                                                                            | `yo koa2-simple-api-generator project_name --useDockerCompose`                      |\n| databaseName      | String  |  null   | Select the database to which the application will connect. Accepts the values: postgresql, mysql, mariadb and mongodb. | `yo koa2-simple-api-generator project_name --databaseName=postgresql`               |\n\n## \u003ca id=\"structure\"\u003e\u003c/a\u003e Project structure\n\nThe project generated by generator-koa2-api-generator includes:\n\n**Default project structure**\n\n- **api (folder)**: In this folder there are project configurations and the src folder that contains the source code\n\n  - **.husky (folder)**: Contains git hook used by husky\n  - **.env (file)**: Contains the API environment variables.\n  - **.env.example (file)**: Contains an example of API environment variables used to create a .env file.\n  - **.eslintignore (file)**: Files and folders ignored by eslint.\n  - **.eslintrc.yml (file)**: Configuration used by eslint.\n  - **.gitignore (file)**: Files ignored by git.\n  - **.lintstagedrc.json (file)**: Configuration used by lintstaged.\n  - **.prettierignore (file)**: Files and folders ignored by prettier.\n  - **.prettierrc.json (file)**: Configuration used by prettier.\n  - **commitlint.config.js (file)**: Congiguration used by commitlint.\n  - **package.json (file)**: Contains dependencies, dev dependencies, scripts, etc.\n  - **README.md (file)**: Documentation generated by generator-koa2-simple-api-generator.\n  - **src (folder)**: Contains the source code:\n    - **config (folder)**: Contains configuration files, for example database.js (contains environment varibles used by sequelize) and jwt.js (contains environment variables used by jsonwebtoken).\n    - **routes (folder)**: Contains the koa routers used by the project.\n      - **authentication (folder)**: Contains functions and routers to authenticate the users with json web token.\n      - **user (folder)**: Contains functions and routes to register, obtain and modify an user. Uses default model user\n      - **index.js (file)**: Contains the main koa2 router with prefix 'api/v1' and mounts the others routers.\n    - **api.js (file)**: Creates and configures the Koa object and it exports the Koa object.\n    - **server.js (file)**: Mounts the API and runs the server.\n\n**Added docker support**:\n\nWhen the Docker support is activate (--useDocker is used), the following files are added to default project in api folder:\n\n- **.dockerignore (file)**: Files and folders ignore to Docker.\n- **Dockerfile (file)**: Used to create a docker image.\n- **docker-entrypoint.sh (file)**: Contains scripts to run migrations in development mode. Used by ENTRYPOINT in Dockerfile.\n- **wait-for-it.sh (file)**: More information, see [wait-for-it.sh in github](https://github.com/vishnubob/wait-for-it). Script used to wait for the database to be enabled to receive connections.\n\n**Added docker compose support**:\n\nWhen the Docker Compose support is activate (--useDockerCompose is used), the following files and folders are added to default.\n\n- **api/.env (file)**: Adds the values ​​corresponding to the database environment variables, for example for postgresql, adds the following environment variables:\n\n```\n  DB_USERNAME=admin\n  DB_PASSWORD=admin\n  DB_NAME=api\n  DB_HOST=database\n  DB_PORT=5432\n\n  DATABASE_URL=postgresql://admin:admin@database:5432/api\n```\n\n- **database (folder)**: Contains files used to create and cofigure the database.\n\n  - **.dockerignore (file)**: Files and folders ignored by docker.\n  - **.env (file)**: Environment variables used the database in docker.\n  - **.env.example (file)**: Contains an example of database environment variables used to create a .env file.\n  - **Dockerfile (file)**: Used to create docker image.\n\n- **In the root folder**:\n  - **docker-compose.yml (file)**: Used to deploy the docker container (API and database), contains the volumen and environment variables used by the API and database, publish the API ports, etc.\n  - **.env (file)**: Contains the environment variables to configure docker-compose.yml file.\n  - **.env.example (file)**: Contains an example of docker-compose.yml environment variables used to create a .env file.\n\n## \u003ca id=\"generators-included\"\u003e\u003c/a\u003e Generators included\n\nThe generators included are:\n\n`koa2-simple-api-generator:app` used by `yo koa2-simple-api-generator`: It is the generator used by default.\n\n`koa2-simple-api-generator:docker`: It is used to add support for Docker. It accepts the options `--useDocker`, `--nodeVersion` and `--projectFolderName`.\n\n`koa2-simple-api-generator:docker_compose`: It is used to add support for Docker Compose. It accepts the options `--useDockerCompose` and `--databaseName`.\n\n## \u003ca id=\"configuring-the-project-automatically\"\u003e\u003c/a\u003e The question: Do you want to automatically run the scripts that configure the package, then installing the dependencies?\n\nWhen you selects the true value, the following scripts ubicated in the package.json are executed:\n\n- `init`\n- `format:fix`\n\nIf you selects the false value, if you want to use husky, you must run `npm run init`.\n\n## \u003ca id=\"scripts\"\u003e\u003c/a\u003e The scripts in package.json\n\nThe more important scripts added into the package.json created by this generator are:\n\n- `\"init\"`: Runs the commands necessary to initialize the package, for example `init:husky`.\n- `\"dev\"`: Runs the application in development mode using nodemon and dotenv.\n- `\"start\"`: Runs the application using node.\n- `\"format\"`: Checks the format using prettier.\n- `\"format:fix\"`: Fixes the format using prettier.\n- `\"lint\"`: static code analysis using eslint.\n- `\"lint:fix\"`: Fixes the code using eslint.\n- `\"commitlint\"`: Runs commitlint. It is used into .husky/commit-msg file. It is called by the commit-msg hook. See [git hook](https://www.atlassian.com/git/tutorials/git-hooks#:~:text=The%20commit%2Dmsg%20hook%20is,file%20that%20contains%20the%20message.).\n- `\"lint-staged\"`: Runs lint-staged. It is used into .husky/pre-commit file. It is called by the pre-commit hook. See [git hook](https://www.atlassian.com/git/tutorials/git-hooks#:~:text=The%20commit%2Dmsg%20hook%20is,file%20that%20contains%20the%20message.).\n- `\"quality-check\"`: Runs `npm run format \u0026\u0026 npm run lint`. It is used into .husky/pre-push file. It is called by the pre-push hook See [git hook](https://www.atlassian.com/git/tutorials/git-hooks#:~:text=The%20commit%2Dmsg%20hook%20is,file%20that%20contains%20the%20message.).\n\n## \u003ca id=\"know-yeoman\"\u003e\u003c/a\u003e Getting To Know Yeoman\n\n- Yeoman has a heart of gold.\n- Yeoman is a person with feelings and opinions, but is very easy to work with.\n- Yeoman can be too opinionated at times but is easily convinced not to be.\n- Feel free to [learn more about Yeoman](http://yeoman.io/).\n\n## \u003ca id=\"author\"\u003e\u003c/a\u003e Author\n\n👤 **Cristopher Jiménez Meza**\n\n- Github: [@cristopher1](https://github.com/cristopher1)\n\n## \u003ca id=\"contributing\"\u003e\u003c/a\u003e 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/cristopher1/generator-koa2-simple-api-generator/issues). You can also take a look at the [contributing guide](https://github.com/cristopher1/generator-koa2-simple-api-generator/blob/master/CONTRIBUTING.md).\n\n## \u003ca id=\"support\"\u003e\u003c/a\u003e Show your support\n\nGive a ⭐️ if this project helped you!\n\n## \u003ca id=\"license\"\u003e\u003c/a\u003e 📝 License\n\nCopyright © 2024 [Cristopher Jiménez Meza](https://github.com/cristopher1).\u003cbr /\u003e\nThis project is [MIT](https://github.com/cristopher1/generator-koa2-simple-api-generator/blob/master/LICENSE) licensed.\n\n---\n\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristopher1%2Fgenerator-koa2-simple-api-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristopher1%2Fgenerator-koa2-simple-api-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristopher1%2Fgenerator-koa2-simple-api-generator/lists"}