Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mass1ve-err0r/api-template
Minimalist boilerplate to create a RESTful API with TypeScript, ExpressJS and JWT.
https://github.com/mass1ve-err0r/api-template
api express-boilerplate expressjs jwt jwt-authentication rest-api restful-api typescript typescript-boilerplate
Last synced: 2 days ago
JSON representation
Minimalist boilerplate to create a RESTful API with TypeScript, ExpressJS and JWT.
- Host: GitHub
- URL: https://github.com/mass1ve-err0r/api-template
- Owner: mass1ve-err0r
- Created: 2020-07-31T23:54:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T09:05:55.000Z (over 1 year ago)
- Last Synced: 2023-03-06T09:04:00.113Z (over 1 year ago)
- Topics: api, express-boilerplate, expressjs, jwt, jwt-authentication, rest-api, restful-api, typescript, typescript-boilerplate
- Language: TypeScript
- Homepage:
- Size: 184 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# api-template
> Simple Stack combining TS, ExpressJS & JWT + Examples## In A Nutshell
This is essentially a basic stack to get started with creating RESTful APIs with Typescript, backed by ExpressJS and secured with JWTs.There is no massive overhead, you can simply clone this repository and get started.
For those who are new to this, router -examples are also included.
- This does __not__ replace following a regular tutorial if you're a newbie, please use this as help/ learning material instead of replacement in that case!## Components
- TypeScript _(duh.)_
- ts-node & ts-node-dev
- ts-dotenv
- jsonwebtoken
- helmet
- express
- body-parser### Appendix A: ts-dotenv
I quite liked ts-dotenv because you're essentially also creating a class to export your .env vars in a more explicit fashion.
A `.env` is not included but essentially you'll just create it at the root of the project _(not inside `/src`)_ and declare the variable's explicit type inside `/src/env.ts`.Simple `.env` Example :
```
# This is a comment btw
PORT=8000
JWT_SECRET=my_super_secret
```Corresponding entry inside `/src/env.ts` :
```
export const schema = {
PORT: Number,
JWT_SECRET: String
};
```### Appendix B: Safety + Comments
- __PLEASE USE A STRONG JWT_SECRET !!!__
- The included gitignore should cover you
- macOS, Windows, Linux, Node, dotenv, JeBrains IDEs (all), VisualStudioCode
- I'm _not_ a TS expert myself but why not share something useful, even if minimal## License
This template is licensed under the MIT License. Feel free to fork, adapt/ modify or whatever!