Simple Example API Rest, using Node, restify, PostgreSQL, Docker and docker-compose.
First we'll clone the project.
$ git clone https://github.com/gustafsilva/example-node-postgres.git
Open the project and install node dependencies.
$ cd example-node-postgres
$ npm install
Run the database in the container.
$ cd postgres
$ docker-compose up -d
Go back to the initial project folder and run the restify server.
$ cd ../
$ npm start
Some lines of the projects are commented (usually of logs
), you can withdraw the comment to facilitate the debug in the terminal
.
You can also run the project in development mode (using nodemode
to capture changes on the server) with the command:
$ npm run start-dev
To run the tests, make sure the database server is running and run the command:
$ npm test
Jest and supertests were used to automate the tests. ❤️
List of commands that can by using npm
:
$ npm install # install all node dependecies
$ npm start # start server
$ npm run start-dev # start development mode server (any change restarts the server)
$ npm test # perfoms all the tests
$ npm run generate-docs # generates html documentation
$ npm run clean-docs # remove html documentation
$ npm run clean # remove documentation in thtml and modules node
You can access the documentation here. Or you can generate locally using the command:
$ npm run generate-docs
Just open the docs/index.html
file in your browser and start browsing... 📗
jsdoc was used for document automation. ❤️
If you have found an error or want to improve the example, create an issue
or pull request
.
The contents of this repository are covered under the MIT License.