When Function found Type: A Starter with Koa and Mongoose in Typescript
MIT License
Typescript Koa Mongoose Starter is the beginning of folks who want to play with Typescript in the backend
Environment variables for local development are found in config.env
For Docker deployments they are found in deploy.env
PORT=3000
MONGO_URI=mongodb://127.0.0.1:27017/test
JWT_SECRET=12345678900987654321zxTypeScript
APP_NAME=typescript-node-example
If you wish to change the port in the env variable, make sure to change the ports inside the docker-compose file if you are using the docker-compose commands in the makefile or in package.json
Install the dependencies and devDependencies and start the server.
$ cd typescript-koa-mongoose-starter
$ npm install
$ npm start
For production environments.. 0_o
$ npm install
$ npm run compose-up
The documentation is outputted in a documentation directory in the root directory.
$ npm run documentation
The service runs on port 3000 by default
Want to contribute? Great! Make a Pr!
Open your favorite Terminal and run these commands.
$ npm run watch
To release in javascript. The output is dumped in the dist folder:
$ npm run build
Content-Type: application/json
Authorization Bearer <JwtToken>
An endpoint that has input and output validation that returns the following information. The password field should be stored in Mongo cryptographically hashed
Type | |
---|---|
first_name | String |
last_name | String |
String | |
password | String |
Type | |
---|---|
id | String |
first_name | String |
last_name | String |
String |
An endpoint that has input and output validation that returns the following information. This uses JWT Tokens.
Type | |
---|---|
String | |
password | String |
Type | |
---|---|
user_id | String |
token | String |
An Authorization Header must be present with Bearer <jwtToken>
returned from login.
An endpoint that returns the user object., and has output validation. This endpoint requires a valid JWT Token
Type | |
---|---|
id | String |
first_name | String |
last_name | String |
String |
An Authorization Header must be present with Bearer <jwtToken>
returned from login.
An endpoint that updates the input of a document and output validation that returns the following information.
Type | |
---|---|
first_name | String |
last_name | String |
Type | |
---|---|
id | String |
first_name | String |
last_name | String |
String |
Uses Jest, Supertest, Chai and MongoDB Memory Server
npm test
-- src
|-- .gitignore
|-- .travis.yml
|-- CHANGELOG.md
|-- Dockerfile
|-- LICENSE
|-- README.md
|-- config.env
|-- deploy.env
|-- docker-compose.yml
|-- jest.config.js
|-- makefile
|-- package-lock.json
|-- package.json
|-- tsconfig.json
|-- tslint.json
|-- version.sh
|-- src
| |-- db.ts
| |-- index.ts
| |-- router.ts
| |-- server.ts
| |-- controller
| | |-- blackhole.ts
| | |-- login.ts
| | |-- health.ts
| | |-- user.ts
| |-- lib
| | |-- jwt.ts
| |-- middleware
| | |-- index.ts
| |-- model
| | |-- user.ts
| |-- router
| | |-- blackhole.ts
| | |-- helper.ts
| | |-- login.ts
| | |-- user.ts
| |-- types
| |-- index.ts
|-- test
|-- blackhole.test.ts
|-- login.test.ts
|-- user.test.ts