Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dxphilo/elk2
https://github.com/dxphilo/elk2
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dxphilo/elk2
- Owner: dxphilo
- License: mit
- Created: 2023-11-14T22:25:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-22T10:02:55.000Z (about 1 year ago)
- Last Synced: 2024-04-23T18:35:49.674Z (8 months ago)
- Language: TypeScript
- Homepage: https://elk2.onrender.com/imagekit
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Boilerplate Nodejs App
A simple boilerplate code for bootstrapping a NodeJS Express backend in Typescript.
## Batteries included
* cors
* body-parser
* compress
* .env environment variables
* simple console logging for requests
* prettier, eslint and nodemon for rapid development## Suggested VSCode Plugins
1. ESLint
2. Prettier
3. DotENV## How to start
1. Create a copy of `example.env` named `.env`
2. `yarn install`
3. `yarn run dev`
4. `Start adding stuff`## Commands
* `yarn start` - Starts the app. Needs to be builded first
* `yarn run build` - Builds the app (typescript compilation)
* `yarn run dev` - Starts nodemon (Auto-restart on changes with auto-rebuild)## FAQ
### Where do I add environment variables?
All of the env variables are handled within the `env.ts` file. This file exports the env variable that includes all the environment variables imported. When you add a new environment variable, make sure to add it to the `.env` file and to the `example.env` file for sharing it with others. **Remember to only put sensitive data on the `.env` file and not on the `example.env` one**.
### How do I add a new controller?
Just copy the hello-world.ts file and start working. Remember afterwards to add an `app.use` statement on the `app.ts` file.
### How do I add a database?
If you want to add mongodb, install the necessary packages (mongodb, mongoose with their respective types) and proceed. For SQL, I suggest typeorm, with the respective driver (mysql, postgres etc).
You will also need to create a new database. The easiest way to achieve that is to create a docker instance. But you can always connect to an already existing mongodb (see [mongodb atlas](https://www.mongodb.com/cloud/atlas)).
## Todo
* Add a testing framework
## License
[MIT](LICENSE)