All Projects → SakaDream → rocket-rest-api-with-jwt

SakaDream / rocket-rest-api-with-jwt

Licence: MIT license
A Rusty Rocket fuelled with Diesel and secured by JWT

Programming Languages

rust
11053 projects
Dockerfile
14818 projects
PLpgSQL
1095 projects

Projects that are alternatives of or similar to rocket-rest-api-with-jwt

mathesar
Web application providing an intuitive user experience to databases.
Stars: ✭ 95 (+53.23%)
Mutual labels:  postgres, restful-api
rfcbot-rs
Coordinates asynchronous decision making on Rust repositories. Status of tracked issues and PRs can be viewed at https://rfcbot.rs.
Stars: ✭ 143 (+130.65%)
Mutual labels:  rocket-rs, diesel-rs
Database-Web-API
Dynamically generate RESTful APIs from the contents of a database table. Provides JSON, XML, and HTML. Supports most popular databases
Stars: ✭ 37 (-40.32%)
Mutual labels:  postgres, restful-api
Satellity
Yet another open source forum written in Golang, React and PostgreSQL.
Stars: ✭ 455 (+633.87%)
Mutual labels:  postgres, restful-api
Evolutility Server Node
Model-driven REST or GraphQL backend for CRUD and more, written in Javascript, using Node.js, Express, and PostgreSQL.
Stars: ✭ 84 (+35.48%)
Mutual labels:  postgres, restful-api
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (+138.71%)
Mutual labels:  postgres, restful-api
Bricks
A standard library for microservices.
Stars: ✭ 142 (+129.03%)
Mutual labels:  postgres, restful-api
shorty
High-performance link shortener
Stars: ✭ 48 (-22.58%)
Mutual labels:  rocket-rs, diesel-rs
FullStack-Angular-SpringBoot
Customer Relationship Managment [Full-stack Web Development using Angular & SpringBoot (RestFull API)]
Stars: ✭ 48 (-22.58%)
Mutual labels:  restful-api
pgxmock
pgx mock driver for golang to test database interactions
Stars: ✭ 97 (+56.45%)
Mutual labels:  postgres
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (-9.68%)
Mutual labels:  postgres
babyfoot
Simple CQRS/ES Node+Express+TypeScript REST API
Stars: ✭ 14 (-77.42%)
Mutual labels:  restful-api
node-crudapi-ts
CRUD boilerplate for create Node Restful API's with Express Framework and Sequelize ORM written in Typescript.
Stars: ✭ 41 (-33.87%)
Mutual labels:  restful-api
SugarRestSharp
SugarRestSharp is a .NET C# SugarCRM/SuiteCRM Rest API Client. It is .NET C# Wrapper for the SugarCRM/SuiteCRM REST API Client.
Stars: ✭ 29 (-53.23%)
Mutual labels:  restful-api
akaash-rest-api
Akaash: A restful API template built with PHP driven by flight micro-framework
Stars: ✭ 17 (-72.58%)
Mutual labels:  restful-api
wgrest
WireGuard REST API
Stars: ✭ 92 (+48.39%)
Mutual labels:  restful-api
Library
Online Library Management. User can search, check in, checkout book. System adds fines automatically if the book is not checked in by due date
Stars: ✭ 27 (-56.45%)
Mutual labels:  restful-api
pgsink
Logically replicate data out of Postgres into sinks (files, Google BigQuery, etc)
Stars: ✭ 53 (-14.52%)
Mutual labels:  postgres
migrant lib
Embeddable migration management
Stars: ✭ 22 (-64.52%)
Mutual labels:  postgres
SimpleGlip
A simple Glip client with RESTful API
Stars: ✭ 20 (-67.74%)
Mutual labels:  restful-api

Rocket REST API with JWT

CI Docker CICD

A Rusty Rocket 🚀 fuelled with Diesel 🛢 and secured by JWT 🔐

Require

You can build and run app from source:

Or using Docker

How to run

Manual

  • Install Rust nightly (Thanks for Rustup 1.20!): rustup install nightly
  • Set Rust Nightly to project: Go to the root of the project, open cmd/terminal and run rustup override set nightly
  • Rename secret.key.sample to secret.key or create your own key by running head -c16 /dev/urandom > secret.key in command line (Linux/UNIX only) and copy to /src folder
  • Create a database in postgres cli or pgAdmin tool
  • Rename Rocket.toml.sample to Rocket.toml and update the database connection string in url key.
  • Build with release profile: cargo build --release
  • Run release binary in command line/terminal. On Windows: target/release/address_book_rest_api.exe, on *UNIX: target/release/address_book_rest_api
  • Enjoy! 😄

Docker

  • Enter into project directory and run docker-compose up
  • Enjoy! 😄

APIs

Address: localhost:8000

POST /api/auth/signup: Signup

  • Request body:
{
   "username": string,
   "email": string,
   "password": string       // a raw password
}
  • Response
    • 200 OK
    {
       "message": "signup successfully",
       "data": ""
    }
    
    • 400 Bad Request
    {
       "message": "error when signing up, please try again",
       "data": ""
    }
    

POST /api/auth/login: Login

  • Request body:
{
   "username_or_email": string,
   "password": string       // a raw password
}
  • Response
    • 200 OK
    {
       "message": "login successfully",
       "data": {
         "token": string      // bearer token
       }
    }
    
    • 400 Bad Request
    {
       "message": "wrong username or password, please try again",
       "data": ""
    }
    

GET /api/address-book: Get all people information

  • Header:
    • Authorization: bearer <token>
  • Response
    • 200 OK
    {
       "message": "ok",
       "data": [
          {
            "id": int32,
            "name": string,
            "gender": boolean,      // true for male, false for female
            "age": int32,
            "address": string,
            "phone": string,
            "email": string
          }
       ]
    }
    

GET /api/address-book/{id}: Get person information by id

  • Param path:
    • id: int32
  • Header:
    • Authorization: bearer <token>
  • Response
    • 200 OK
    {
       "message": "ok",
       "data": {
         "id": int32,
         "name": string,
         "gender": boolean,      // true for male, false for female
         "age": int32,
         "address": string,
         "phone": string,
         "email": string
       }
    }
    
    • 404 Not Found
    {
       "message": "person with id {id} not found",
       "data": ""
    }
    

GET /api/address-book/{query}: Search for person information by keyword

  • Param path:
    • query: string
  • Header:
    • Authorization: bearer <token>
  • Response
    • 200 OK
    {
       "message": "ok",
       "data": [
         {
           "id": int32,
           "name": string,
           "gender": boolean,      // true for male, false for female
           "age": int32,
           "address": string,
           "phone": string,
           "email": string
         }
       ]
    }
    

POST /api/address-book: Add person information

  • Header:
    • Authorization: bearer <token>
  • Request body:
    {
      "name": string,
      "gender": boolean,      // true for male, false for female
      "age": int32,
      "address": string,
      "phone": string,
      "email": string
    }
    
  • Response
    • 201 Created
    {
      "message": "ok",
      "data": ""
    }
    
    • 500 Internal Server Error
    {
      "message": "can not insert data",
      "data": ""
    }
    

PUT /api/address-book/{id}: Update person information by id

  • Param path:
    • id: int32
  • Header:
    • Authorization: bearer <token>
  • Request body:
{
  "name": string,
  "gender": boolean,      // true for male, false for female
  "age": int32,
  "address": string,
  "phone": string,
  "email": string
}
  • Response
    • 200 OK
    {
      "message": "ok",
      "data": ""
    }
    
    • 500 Internal Server Error
    {
      "message": "can not update data",
      "data": ""
    }
    

DELETE /api/address-book/{id}: Delete person information by id

  • Param path:
    • id: int32
  • Header:
    • Authorization: bearer <token>
  • Response
    • 200 OK
    {
      "message": "ok",
      "data": ""
    }
    
    • 500 Internal Server Error
    {
      "message": "can not delete data",
      "data": ""
    }
    

Errors:

  • Invalid or missing token
    • Status code: 401 Unauthorized
    • Response:
    {
      "message": "invalid token, please login again",
      "data": ""
    }
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].