Skip to content

pacyL2K19/api

 
 

Repository files navigation

api

Open in Gitpod

Description

An API to manage our #EddieHub community data.

Rules

  • Commits follow the standard Conventional Commit
  • Branches should be named as issue-<issue no> (e.g. NestJS issue number is 12)

Requirements

  • docker
  • node
  • npm

Installation

Gitpod

Gitpod is a Service, which provides development environments in the cloud. In case no plan is purchased the regular Opensource License allows to use the service for 50 hours per month for free.

All that needs to be done, is logging in to their service with a valid GitHub account.

  1. Install the Browser Extension from Gitpod. [OPTIONAL]
    - Chrome
    - Firefox
  2. Just hit the Gitpod button in the README file. Everything will spin up automatically.
  3. When you're finished with your contribution just close the workspace.

Running the app locally

$ npm install

When using gitpod, you can set environment-variables under the following link https://gitpod.io/variables. You can even scope the variable to a specific project.

For connecting the API against the database you can use docker-compose

# database
$ docker-compose up
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

API-Token

  • The API-Token is a static token, which gets set in the environment-variables as APPROVED_TOKENS.
  • This token is used to authenticate an 'admin-App' against the API. The API-Token is used to generate Bearer-Tokens.
  • For generating more than one token they can be passed to the environment-variables as a comma-separated list.

Swagger docs

  1. start the app npm start
  2. visit http://localhost:3000/swagger

Official docs at https://docs.nestjs.com/openapi/introduction

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Logging

Logging can be turned on by settings an environment-variable DEBUG=true. If this variable is not true or undefined no Logs will be made.

When set to true the App will Log every incoming request.

Authentication

Authentication is handled via an environment-variable called APPROVED_TOKENS. The approved tokens which are validated by the API are put there. In case there should be multiple tokens, for multiple clients, they need to be comma-separated.

To use Authentication the token needs to be passed in the token-header of the client-request.

Docker

Build the Docker container

  1. docker build -t eddiehub-api .
  2. docker run -p 3000:3000 -d eddiehub-api
  3. Visit http://localhost:3000/

Running the app via Docker on GitHub Container Registry

  1. docker run -p 3000:3000 -d ghcr.io/eddiehubcommunity/api:latest
  2. Visit http://localhost:3000/

License

MIT licensed.

Socials

  • Join our Discord community here
  • Subscribe to our YouTube channel here

Our Pledge

We take participation in our community as a harassment-free experience for everyone and we pledge to act in ways to contribute to an open, welcoming, diverse and inclusive community.

If you have experienced or been made aware of unacceptable behaviour, please remember that you can report this. Read our Code of Conduct.

About

API to manage our community data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 82.9%
  • Gherkin 14.3%
  • JavaScript 1.6%
  • Other 1.2%