Skip to content

gustafsilva/example-node-postgres

Repository files navigation

Example Simple API with Node Postgres + Restify

Simple Example API Rest, using Node, restify, PostgreSQL, Docker and docker-compose.

Getting Started 🚀

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

With NPM

$ npm install 

With YARN

$ yarn 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 ../

With NPM

$ npm start

With YARN

$ yarn start

Ready! 👍 You can already hack the project. 😎

Dependencies

Debugging project

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

Tests

To run the tests, make sure the database server is running and run the command:

$ npm test
// or
$ yarn test

Jest and supertests were used to automate the tests. ❤️

Automated commands 🔥

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

List of commands that can by using yarn:

  $ yarn install # install all node dependecies
  $ yarn start # start server
  $ yarn run start-dev # start development mode server (any change restarts the server)
  $ yarn test # perfoms all the tests 
  $ yarn run generate-docs # generates html documentation
  $ yarn run clean-docs # remove html documentation
  $ yarn run clean # remove documentation in thtml and modules node

Documentation

You can access the documentation here. Or you can generate locally using the command:

$ npm run generate-docs
// or
$ yarn run generate-docs

Just open the docs/index.html file in your browser and start browsing... 📗

jsdoc was used for document automation. ❤️

More informations

Single entity of the database:

Contribution

If you have found an error or want to improve the example, create an issue or pull request.

Contributors

Gustavo Freitas - Creator

Evan Burrell

Licence

The contents of this repository are covered under the MIT License.

About

Simple example node and the node-postgres collection

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published