Starting point for creating web app or API with Express and Typescript. After fighting with myself about design, I finally decided to go with more "classy" approach in mind. Folder structure is heavily influenced by how Laravel did it.
Currently, this setup will work only locally. If this condition is satisfied continue with the instructions below.
- Install dependecies
npm install
- Copy env.example and configure .env
cp .env.example .env
Option | Predefined values | Description |
---|---|---|
NODE_ENV | development, production | Define in what environment are you working currently. Set to development if you need to test, debug, etc. |
DB_HOST | localhost | Currently starter works only locally |
DB_PORT | 27017 | Default is 27017 |
DB_NAME | Place for your db name. | |
DB_USERNAME | Place for your db username. If db is not protected leave this value empty. | |
DB_PASSWORD | Place for your db password. If db is not protected leave this value empty. | |
PORT | 9000 | Could be any. Default is set to 9000 |
SESSION_KEY | Protect sessions with this key. | |
API_PREFIX | Here is where you define url prefix for APIs calls. Route example: /API_PREFIX/users/get |
|
API_KEY | Secret api key placed in request header. Header example: x-api-key: secretapikey |
|
LOGS | ON, OFF | Just a switch for log activity. |
MAIL_HOST | Define mail service. Example: gmail |
|
MAIL_PORT | TLS protocol use 587 as standard. For SSL set value to 465 |
|
MAIL_USERNAME | Sender email. Example: [email protected] | |
MAIL_PASSWORD | Sender password. |
- Start mongoDB server
mongod
- Start project
npm start
Get started by navigating to http://localhost:9000