Skip to content

JasonXu314/chatterbox-backend

Repository files navigation

Installation & Local Testing

Requirements:

Running

Run

$ yarn install

to install dependencies, and

$ yarn dev

to run the local server

Make sure your MySQL server is running on port 3306 before running server

Running the app

# development
$ yarn start

# watch mode
$ yarn dev

# production mode
$ yarn start:prod

Endpoints

POST /signup
Body {
	username: string
	password: string
}
Response {
	id: number
	username: string
	avatar: string
	token: string
}
POST /login
Body {
	username: string
	password: string
}
Response {
	id: number
	username: string
	avatar: string
	token: string
}
GET /users
GET /users?id=number
GET /users/[id: number]
Response {
	id: string
	username: string
	avatar: string
}
POST /create-message
Body {
	channelId: number
	content: string
	token: string
}
Response {
	id: number
	channelId: number
	authorId: number
	content: string
	createdAt: Date
}
POST /set-avatar
Body (FormData) {
	file: File
	token: string
}
Response string
GET /channels?token=string
Response {
	id: number
	name: string
	type: 'public' | 'direct'
}[]
GET /friends?token=string
Response {
	id: string
	username: string
	avatar: string
	channelId: string
}[]
POST /request-friend
Body {
	token: string
	id: number 		// the id of the request recipient
}
Response none
POST /accept-request
Body {
	token :string
	id: number		// the id of the requester
}
Response (the new friend) {
	id: string
	username: string
	avatar: string
	channelId: string
}
POST /friend-requests?token=string
Response {
	from: (the sending user) {
		id: number
		username: string
		avatar: string
	}
	timestamp: string
}[]

Test

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published