Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.
/ backend-nestjs Public archive

schoolsyst's backend API, rewritten in NestJS by @LeGmask

Notifications You must be signed in to change notification settings

schoolsyst/backend-nestjs

Repository files navigation

schoolsyst's API

Authentification

All routes require a JWT token to access (except /auth/ routes)

To access routes, first obtain your token, then, pass it in the Authorization header using the format Bearer <your token>.

Common objects

Some objects are reused in a number of routes. Their properties are listed here.

Subject

Represents a subject of the user.

Property Type Constraints Description
name string max length: 100
required.
The subject's display name.
slug slug max length: 100
must be unique to the user.
Derived from the name, contains only alphanumerical characters and the dash "-". Case insensitive.

|

Routes

POST /auth/

Obtain a JWT token, given a email and a password.

Provide the email and password in the request's body as such:

{
  "email": "<your email>",
  "password": "<your password>"
}

The response will be of the following form:

{
  "access": "<your access token>",
  "refresh": "<your refresh token>"
}

POST /auth/refresh/

Renew your access token provided the refresh token

Given the refresh token:

{
  "refresh": "<your refresh token>"
}

The response will contain the new access token:

{
  "access": "<your new access token>",
}

GET /users/self/

Information about the current user (the one authentificated by the access token)

The response will contain:

  • email - unique (case insensitive)
  • activated - Whether or not the user has confirmed his email address.

POST /users/

Create an account.

The request must contain:

  • email
  • password

Upon registration, the API...

  1. creates a new unique activation token and saves it on <the user>.activation_token
  2. sends a confirmation email to email, this email contains a button that links to https://api.schoolsyst.com/users/activate/?token=<the verify token>&email=<the email address>

POST /users/activate

Query parameters:

Name Type Constraints Description
email email address Exists in the database
token string Exists in the database Stored as a property named activation_token on each user. Destroyed 24 hours after creation.

Routes beyond this point require the user to have its activation state (activated property) set to true. Otherwise a 401 Unauthorized response will be sent.


/settings/

Settings of the user.

Name Type Constraints Default value Description
theme One of 'light', 'dark' or 'auto' 'auto'

|


Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Gitter Backers on Open Collective Sponsors on Open Collective

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

schoolsyst's backend API, rewritten in NestJS by @LeGmask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published