Skip to content

Repository files navigation

projet-02-playground-explorer-back

Project setup

You will need to setup the project by following these steps:

  1. Clone the repository:
git clone
  1. Install the dependencies:
npm install
  1. Create a .env file at the root of the project and add the following environment variables:
PORT=3000
PG_URL=postgresql://postgres:postgres@localhost:5432/playground
JWT_SECRET=SECRETKEYSTRING
DEPLOY_URL=http://localhost:3000
SESSION_SECRET=SECRETKEYSTRING
MONGO_URL=mongodb://localhost:27017/playground-session
ENV=DEV
  • PORT: The port on which the server will run.
  • PG_URL: The URI of the PostgreSQL database.
  • JWT_SECRET: The secret key used to sign the JWT tokens.
  • DEPLOY_URL: The URL of the server. ACTUALLY NOT USED
  • SESSION_SECRET: The secret key used to sign the session cookies.
  • SESSION_SECRET_STATS: The secret key used to keep data.
  • MONGO_URL: The URI of the MongoDB server.
  • ENV: The environment in which the server is running (DEV, PROD). It is used to enable/disable some features about sequelize logging and ssl.
  1. Run the server:
npm start
  1. The server should now be running on the specified port.

Database setup

This project uses a PostgreSQL database. You can set up a local database by following these steps:

  1. Use the following script to create a new database and add tables to it :
npm run db:create
  1. Use the following script to populate the database with data :
npm run db:seed
  1. Use the following script to drop the database :
npm run db:drop
  1. Use the following script to reset (drop, create and populate) the database :
npm run db:reset && npm run db:seed

Running mongodb

MongoDB is used for the admin authentication. You can run a local MongoDB server by following these steps:

  1. Install MongoDB on your machine.

  2. Run the following command to start the MongoDB server:

mongod
  1. Set the URI of the MongoDB server in the .env file:
MONGO_URL=mongodb://localhost:27017/playground-session

Admin dashboard

Administrator dashboard is usable at localhost:PORT/.

Deploy on heroku

To deploy the server on heroku, you will need to follow these steps:

  • setup a PG database on heroku
  • setup a MongoDB database on heroku
  • setup a heroku app
  • set the environment variables on heroku
  • push the code to heroku using git or heroku CLI : git push heroku master

API documentation

About

L'API express de Playground explorer.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages