{"id":18895916,"url":"https://github.com/nhtua/koa-starter-kit","last_synced_at":"2025-04-15T01:34:10.000Z","repository":{"id":96306956,"uuid":"102014748","full_name":"nhtua/koa-starter-kit","owner":"nhtua","description":"Koa Starter Kit is a basic boilerplate for the quick starting with Koa2","archived":false,"fork":false,"pushed_at":"2020-02-18T02:06:47.000Z","size":40,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T13:38:23.323Z","etag":null,"topics":["api","boilerplate","javascript","koa","koa2","restful","starter-kit"],"latest_commit_sha":null,"homepage":"","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/nhtua.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":"2017-08-31T15:18:11.000Z","updated_at":"2024-11-01T03:53:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"834ad1e6-af61-4a82-84e8-5ca6748b5215","html_url":"https://github.com/nhtua/koa-starter-kit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhtua%2Fkoa-starter-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhtua%2Fkoa-starter-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhtua%2Fkoa-starter-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhtua%2Fkoa-starter-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhtua","download_url":"https://codeload.github.com/nhtua/koa-starter-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989526,"owners_count":21194608,"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","boilerplate","javascript","koa","koa2","restful","starter-kit"],"created_at":"2024-11-08T08:31:15.181Z","updated_at":"2025-04-15T01:34:09.994Z","avatar_url":"https://github.com/nhtua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Koa Starter Kit\n\nKoa Starter Kit (KSK) is a basic boilerplate for the quick starting with Koa2. It was written in ES6 with a little messily primitive Javascript syntax that helps you get started building NodeJS API easier than ever.\n\nKSK includes some lovely common setup:\n\n- [x] `src` structure based-on Javascript modules\n- [x] Watching file changes then reload the server\n- [x] Build production with Babel\n- [x] Routing, multi routers\n- [x] Middlewares\n- [x] CORS accepts request from domain white list\n- [x] Authentication with JSON Web Token \n- [ ] Authorization with built-in solution\n\nwant more? Folk and submit your regular tasks.\n\n### Requirement\nKSK requires Node \u003e= 8.6 or higher.\n\n### Getting Started\nFirst we'll clone source code from [GitHub Repo](https://github.com/nhtua/koa-starter-kit.git)\n\n```shell\n  git clone https://github.com/nhtua/koa-starter-kit.git\n```\n\nThen we need to install the dependencies\n\n```shell\ncd koa-starter-kit\nnpm install\n```\n\nNext, make your own environmental config file:\n```shell\ncp src/config/development.example.json src/config/development.json\n```\n\nFinally, run the serve\n\n```shell\nnpm start\n```\n\n### Dev's shortcuts\nThere are npm commands for dev's stuff.\n\n- Run the server during the development\n```shell\nnpm start\n```\n\n- Build and transpile code into Javascript for production\n```shell\nnpm run build\n```\n\n- Run server as production (run the Js transpiled code)\n```shell\nnpm run serve\n```\n\n- Do the UnitTest\n```shell\nnpm run test\n```\n\n### The REST Api\nKSK has three api endpoints for demonstration purpose.\n\nYou need to setup domains white list before you can use any api endpoints in React, Angular or Vuejs application.\nYou'll find the white list at: `src/config/index.js` (someone please help me turn the config file into multi enviroments config!)\n\n#### /login\nLogin to get the jwt token.\n\n- request config:\n  + Method: POST\n  + Header: \n  ```plain-text\n  Content-Type : application/json\n  ```\n\n- input: JSON as Raw body\n  ```json\n  {\n    \"username\": \"john_doe\",\n    \"password\": \"123456\"\n  }\n  ```\n\n- output:\n```json\n{\n    \"error\": false,\n    \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJqb2huX2RvZSIsInN0YXR1cyI6MSwidXBkYXRlZF9hdCI6IjIwMTctMDgtMzEgMDA6MDA6MDAiLCJpYXQiOjE1MDQyMDA2Mzd9.lVRnRCNB7-5zeq_DKtw0jzn_reTCKK5sYC3csIo-Je4\",\n    \"user\": {\n        \"id\": 1,\n        \"username\": \"john_doe\",\n        \"password\": \"$2a$10$TjZ4eIUYrxpF1IZ2zzU8Sel5BH6jFmdZey0L.Bmftw5apgd44hiHu\",\n        \"email\": \"john.doe@email.com\",\n        \"permission\": 7,\n        \"status\": 1,\n        \"updated_at\": \"2017-08-31 00:00:00\",\n        \"created_at\": \"2017-08-31 00:00:00\"\n    },\n    \"message\": \"Logged in successfully!\"\n}\n```\n\n#### /user\nGet user list\n\n- request config:\n  + Method: GET\n  + Header: \n  ```plain-text\n  Content-Type : application/json\n  Authorization : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJqb2huX2RvZSIsInN0YXR1cyI6MSwidXBkYXRlZF9hdCI6IjIwMTctMDgtMzEgMDA6MDA6MDAiLCJpYXQiOjE1MDQyMDA2Mzd9.lVRnRCNB7-5zeq_DKtw0jzn_reTCKK5sYC3csIo-Je4\n  ```\n\n- input: NONE\n\n- output:\n```json\n[\n    {\n        \"id\": 80978,\n        \"username\": \"neal_carter\",\n        \"email\": \"Zaria.Batz49@gmail.com\",\n        \"avatar\": \"https://s3.amazonaws.com/uifaces/faces/twitter/vytautas_a/128.jpg\",\n        \"updated_at\": \"2017-04-04T07:00:50.812Z\"\n    },\n    {\n        \"id\": 68624,\n        \"username\": \"meta_pollich\",\n        \"email\": \"Rylee.Casper67@yahoo.com\",\n        \"avatar\": \"https://s3.amazonaws.com/uifaces/faces/twitter/bereto/128.jpg\",\n        \"updated_at\": \"2016-11-02T15:54:55.781Z\"\n    },\n    ...\n]\n```\n\n#### /user/:id\nGet specific user info (/user/2 ~ get user info who has id = 2)\n\n- request config:\n  + Method: GET\n  + Header: \n  ```plain-text\n  Content-Type : application/json\n  Authorization : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJqb2huX2RvZSIsInN0YXR1cyI6MSwidXBkYXRlZF9hdCI6IjIwMTctMDgtMzEgMDA6MDA6MDAiLCJpYXQiOjE1MDQyMDA2Mzd9.lVRnRCNB7-5zeq_DKtw0jzn_reTCKK5sYC3csIo-Je4\n  ```\n\n- input: NONE\n\n- output:\n```json\n{\n    \"id\": \"2\",\n    \"username\": \"davon_corwin\",\n    \"email\": \"Maurine.Koepp79@yahoo.com\",\n    \"avatar\": \"https://s3.amazonaws.com/uifaces/faces/twitter/areandacom/128.jpg\",\n    \"updated_at\": \"2016-11-24T13:29:42.484Z\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhtua%2Fkoa-starter-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhtua%2Fkoa-starter-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhtua%2Fkoa-starter-kit/lists"}