Skip to content

multei/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multei! API

All Contributors

Travis Build Status

Before everything...

Check out project board

You can find it at https://github.com/orgs/multei/projects/1

Check our guidelines & code of conduct

Check the best practices

We are working to follow Node.js Best Practices.

For more information about Node.js on Heroku, see Best Practices for Node.js Development.

Check our Tech Stack

We have our own Tech Radar

Languages, libraries and frameworks

  • Express;
  • express-api-problem to handle API problems with ease.
  • Google Cloud Storage JavaScript SDK;
  • JavaScript;
  • Multer;

Platforms

Tools

Configure your local dev environment

Install these requirements

Make sure you have installed the following dependencies:

Provide a local database

  1. Install Knex CLI (and all the other dependencies);

    npm install
  2. Make sure you have created the Multei database on Postgres. To create, you can use psql to run:

    psql -U postgres -h localhost -c "create database multei"
  3. Run all migrations

    knex migrate:latest
  4. Run seed files

    knex seed:run

Define the local .env variables

Make sure you have created your own .env file based on .env.example with your credentials.

Start developing

npm install && npm run develop:heroku

The port exposed by the API depends on the start command executed

  • Port 3000 if you run npm start or npm run debug
  • Port 5000 if you run npm run develop:heroku

Deploying to Heroku

  1. Make sure you have created a bucket with viewing permissions to allUsers and allAuthenticatedUsers on Google Cloud Platform;
  2. Make sure you have created a service account only (with key) for production with adequate permissions;
  3. Set a config var called GCP_KEY_FILE with a path to Google Cloud Platform key file;
npm run deploy:heroku

Google Cloud Storage

This API uploads images to the Google Cloud storage service. To be able to upload, you need to have a service account on Google Cloud Storage with the adequate permissions.

So you need to:

  1. Go to APIs & Services;
  2. On the menu on the left panel, tap on Credentials;
  3. At Service Accounts section, tap on Manage Service Accounts;
  4. Click on Create Service Account;
  5. Type a name, ID and description for the new Service Account;
  6. On Service account permissions (optional), add a role with permissions to view and create objects on storage;
  7. Click on Continue;
  8. On Create a key (optional), click on +Create Key;
  9. On Key type, choose the JSON (recommended) option;
  10. Click on Create. The JSON key file will be downloaded;
  11. Put this key file on config/ directory on the repository (create the directory if it does not exist); Never commit this file!
  12. At local development environment, on your .env file, set GOOGLE_APPLICATION_CREDENTIALS to config/multei-{key}.json, where multei-{key}.json is the actual filename;
  13. If your application was already running, restart it.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Jimmy Andrade

🐛 📆 👀 💻 📖 💡

Túlio Assis

💻 📖 🚧 📆

hpsmatheus

🤔
__

This project follows the all-contributors specification. Contributions of any kind welcome!