Routes and APIs - garageScript/databases GitHub Wiki
Introduction
We need the following routes and API endpoints to power the following pages:
- Landing
- Login
- Signup
- Email Confirmation
- Database Setup
- Databases
Routes
The follow routes would be needed to power the pages above
/login
Renders the login page
/signup
Renders the signup page
/
- Renders landing page if user is not logged in
- Renders render email confirmation page if user has not confirmed email.
- Renders database setup page if user has not created a database password.
- Renders the databases page
/logout
Destroys user's session cookies and redirects to /
landing page.
APIs you need
/api/session
POST Used by:
- Login Page
Request body
passwords are base64 encoded so that if engineers are debugging something in production, they don't accidentally see each other's password.
{
email: '[email protected]',
password: 'base64 encoded password'
}
Response
Success
{
status: 'success'
}
Error
{
error: {
messages: ["username / password combination is not valid"]
}
}
/api/users
POST Used by
Request Body
{
username: 'username',
password: 'base64 encoded password',
email: '[email protected]'
}
Response
Success
{
status: 'success'
}
Error
{
error: {
message: ["username is taken", "password is too short", "email is invalid"]
}
}
/api/notification
POST Used by
- Reset Password Email - Send Password Reset Email
Request Body
{
type: 'email',
category: 'resetPassword',
email: '[email protected]'
}
Response
Success
{
status: 'success'
}
Error
{
error: {
message: 'Email delivery failed. Please try again.'
}
}
/api/users/:id
PATCH This updates the user with a database password for that user to use to create all databases.
Used By
Request body
{
password: 'base64 encoded password'
}
Response
Success
{
status: 'success'
}
Error
{
error: {
message: 'database setup failed'
}
}
/api/users/:id/databases
POST Create a database for the currently logged in user
Used by:
Request Body
base64 encoded JSON string
{
name: 'postgres'
}
Response
Success
{
status: 'success'
}
Error
{
error: {
message: 'failed to create database'
}
}
/api/databases
GET Get all databases for the currently logged in user.
Used by:
Response
Success
{
data: [{postgres: {connectionInfo:{...}}}, {mongoDB: {connectionInfo:{...}}, {neo4J: {connectionInfo: null}}}]
}
Error
{
error: {
message: 'failed to get databases'
}
}