This project was made for studying purposes, and it's based on the free course below, held by Waldemar Neto from Dev Lab.
"From zero to production: Learn to build a Node.JS API with TypeScript"
- NodeJS (>= 12.0.0)
- TypeScript
- Jest
- Mongoose
- GitHub Actions
-
Clone the repository:
git clone https://github.com/felipebelinassi/node-typescript-api.git <project_name>
-
Install dependencies:
yarn
ornpm install
-
Build and run the project:
yarn start
ornpm start
-
Start MongoDB using Docker (optional):
docker-compose up -d
-
Run the project in development mode (using Nodemon):
yarn start:dev
ornpm run start:dev
-
Run unit and functional tests:
yarn test
ornpm test
As stated above, this API uses MongoDB as it's database, and requires it to be running before starting the server. You can create a free database using MongoDB Atlas or run a local instance using Docker. A docker-compose file has been aded to the project with a simple MongoDB instance. To start it locally run: docker-compose up -d
, and then your MongoDB instance will be running at localhost:27017.
The documentation uses the OpenAPI 3.0 standard. You can access the API documentation using the /docs
endpoint after running the project.
This project uses dotenv package to manage environment variables. To set your variables, create a .env file (or just rename the .example.env), which contains all the environments needed to run the application. All variables are required.
- PORT -> Port where the server will start (Heroku set this environment automatically).
- LOGGER_ENABLED -> Flag to indicate if application will log messages using Pino logger.
- LOGGER_LEVEL -> Level to log messages.
- MONGODB_URL -> MongoDB connection url.
- JWT_SECRET_KEY -> Secret value that JWT tokens should be signed with.
- STORM_GLASS_API_URL -> Storm Glass API service base url.
- STORM_GLASS_API_TOKEN -> Storm Glass service API token.
This project is currently deployed on Heroku. You can make some requests using the following base url:
https://belinassi-surf-forecast.herokuapp.com