Backend for enotes, written in node.js and running express.js
Max file uplaod is 64MiB, extra data will be chopped off
GET /api
will respond with some basic data
{
"status": "success",
"name": "enotes api",
"credits": "zhao yun",
"logged_in_as": "your_email_here",
"ip": "::1",
"ips": [],
"server_time": 1591676400000,
"server_uptime": 1337,
"cpus": 96,
"memory": {
"free": 67759802097,
"total": 68719476736,
"usage": 0.013965104
}
}
GET /api/csrf
will give you your csrf token
{
"token": "S52gvcmw-_k-nmQgkHfABHjwhYQAm_NZlPpg"
}
If response has a status
field and it does not equal success
most likely an error occurred. In most cases
check .reason
.
/api/auth
/api/roles
/api/users
/api/audits
/api/collections
GET /api/auth
Current user, including profile
POST /api/auth
Authenticate your token and create a session with set-cookie
token
the jwt token
POST /api/auth/profile
Edit your profile
nickname
Nicknamedesc
Description
POST /api/auth/pfp
Upload new profile picture
file
the file
Note use FormData for file upload
GET /api/auth/logout
Revoke session token validity
GET /api/roles
Get all roles
GET /api/roles/:rid
Get specified role
GET /api/roles/:rid/users
Get all users with specified role
POST /api/roles/:rid/users
Mass grant/revoke users with specified role
action: 'add'|'remove'
action to takeuids: string[]
uids if is to give to users specifiedemails: string[]
emails if is to ...
{
"updated": 0,
// number of users updated
"users": [
User...
]
}
DELETE /api/roles/:rid
Delete said role
POST /api/roles/:rid
Create new role
rid
Redundancyname
desc
defaultPerm: boolean
permissions: {[cid:string]: boolean}
POST /api/roles/:rid/admin
Edit said role
name
desc
defaultPerm: boolean
permissions: {[cid:string]: boolean}
GET /api/users
return all users, cached for 1 minute
GET /api/users/:uid
fetch said user including profile
POST /api/users/:uid
edit said user
roles
role id arraypermissions: {[cid:string]: boolean}
manual overrideteacher
if is teachername
namenick
nicknameadmin
if is admin, will modify custom claims in firebaseaccess
binary encoded permission flags for overriding inherited permissions, uses OR operation
{
"status": "...",
"user": User
}
volatile api
GET /api/collections
return all collections visible to current user
GET /api/collections/:cid
return specified collection
GET /api/collections/:cid/notes
return nots in collection
GET /api/collections/:cid/roles
return roles with access to collection
POST /api/collections/:cid/reorder
reorder notes in collection
[note id]
:note position
{
"notes": [
Note...
]
}
POST /api/collections/:cid
modify specified collection
action: 'add'|'edit'
action to takename
desc
open
{
"status": "...",
"collection": Collection
}
POST /api/collections/:cid/access
modify users allowed to view collection
emails
users to give access to
{
"status": "...",
"collection": Collection
}
DELETE /api/collections/:cid/access
clear modified view access
{
"status": "...",
"collection": Collection
}
DELETE /api/collections/:cid
delete said collection
GET /api/collections/:cid/img
get images in collection
[
{
"url": "https://storage.googleapis.com/e-notes-nush.appspot.com/collections/CS2231_AY2022/images/fig1.1.png",
"name": "fig1.1.png"
},
{
"url": "https://storage.googleapis.com/e-notes-nush.appspot.com/collections/CS2231_AY2022/images/fig1.10.png",
"name": "fig1.10.png"
},
{
"url": "https://storage.googleapis.com/e-notes-nush.appspot.com/collections/CS2231_AY2022/images/fig1.11.png",
"name": "fig1.11.png"
}
]
POST /api/collections/:cid/img
upload single image to collection
file
remember to specify file name, will respect file name
DELETE /api/collections/:cid/img/:img
delete said image by file name