This repository will help you setting up an Express server faster
MASTER branch features:
- Initial Express setup
- Typescript setup
- Folder structure setup
package.json
scripts setup- Error handling setup
- .env setup
- Helmet for protection
TYPEORM branch features:
- All master's branch features
- Typeorm setup
package.json
scripts setup taking into account typeorm- Basic example included (create Book, list Books)
- First clone the repository branch you want with
git clone --single-branch --branch <branchname> https://github.com/Gust4voSales/Express-Server-Boilerplate.git
- Then remove the remote reference to this repository
git remote remove origin
- The local branch's name from your project will be the same as the one you've cloned, so optionally rename the local branch name (to master for example)
git branch -m <new_branch_name>
yarn
to install all dependecies- Create a
.env
file in the root directory and fill it in like.env.example
- Now you're good to go
yarn dev
will start the server in development mode. The project will reload automatically due to changes in files (thanks to ts-node-dev lib already installed)yarn build
will compile all the project to a./dist
folderyarn start
before this command,yarn prestart
hook will run to make sure the project is compiled (in the typeorm branch is also going to ensure the migrations run before starting) and the it will start the server
To run yarn start
or manually run the compiled version from the server (./dist/src/server.js
), make sure the node enviroment is set to production, if necessary, manually change NODE_ENV
from .env
file to production