Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b13eb63
working ts
kristbsy Feb 26, 2025
a41f277
Merge pull request #1 from boolean-uk/migrate-ts
kristbsy Feb 26, 2025
5d87c0c
ts typing user
kristbsy Feb 26, 2025
ebe334f
fixed user validation
kristbsy Feb 26, 2025
afbc84c
Merge pull request #10 from boolean-uk/types-user
kristbsy Feb 26, 2025
21328dc
Added typing cohort
kristbsy Feb 26, 2025
ed61d67
Merge pull request #12 from boolean-uk/typing-cohort
kristbsy Feb 26, 2025
bd78998
add: cohort crud
Enock97 Feb 26, 2025
28324e9
Typing auth
kristbsy Feb 26, 2025
ce5a946
Merge pull request #17 from boolean-uk/typing-auth
Ateeb020301 Feb 26, 2025
be3f238
Removed all eslint errors + hotfix
kristbsy Feb 26, 2025
f88d848
Merge pull request #18 from boolean-uk/typing
Ateeb020301 Feb 26, 2025
b23d944
Removed error checks
kristbsy Feb 26, 2025
2e357a1
Merge pull request #20 from boolean-uk/fix/registration
Ateeb020301 Feb 26, 2025
7f683cd
update: cohort crud
Enock97 Feb 27, 2025
55df131
Merge branch 'main' into enockladu-#3-cohort-crud
kristbsy Feb 27, 2025
04c6819
Merge pull request #19 from boolean-uk/enockladu-#3-cohort-crud
kristbsy Feb 27, 2025
5a0fd40
tsc checking
kristbsy Feb 27, 2025
6435a12
Merge pull request #23 from boolean-uk/error-checking
Ateeb020301 Feb 27, 2025
ef27e79
updated readme
kristbsy Feb 27, 2025
4706f81
added back todo comment
kristbsy Feb 27, 2025
3fba787
Merge pull request #24 from boolean-uk/readme
Ateeb020301 Feb 27, 2025
6480a13
fixing post
abdi0609 Feb 27, 2025
28352e7
fixing merge conflicts
abdi0609 Feb 27, 2025
128ab84
added name to cohort
kristbsy Feb 27, 2025
da4c484
Merge pull request #31 from boolean-uk/cohort-name
Ateeb020301 Feb 27, 2025
1c32954
added role field to jwt token
kristbsy Feb 27, 2025
fb3667e
Merge pull request #34 from boolean-uk/jwt-role
Ateeb020301 Feb 27, 2025
6dacf70
fixed merge conflicts
abdi0609 Feb 27, 2025
70f7943
added simple ci
kristbsy Feb 27, 2025
6763a96
added script for tsc
kristbsy Feb 27, 2025
b84e30a
Merge pull request #37 from boolean-uk/simple-ci
Ateeb020301 Feb 27, 2025
880df90
fixed merge conflicts
abdi0609 Feb 27, 2025
93fb5aa
Merge branch 'main' of https://github.com/boolean-uk/team-dev-server-…
abdi0609 Feb 27, 2025
9f2016b
fixed tsc errors and got post functionalities working
abdi0609 Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: CI
on: [push, pull_request]
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
JWT_TOKEN: ${{ secrets.JWT_TOKEN }}
JWT_EXPIRY: ${{ secrets.JWT_EXPIRY }}
jobs:
test:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- run: npm ci
- run: npx eslint src
- run: npx prisma migrate reset --force --skip-seed
- run: npm run lint
- run: npm run tsc
21 changes: 0 additions & 21 deletions .github/workflows/deploy.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx eslint src
npm run lint
npm run tsc
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Setting up

### Quick guide

1. Setup .env
2. run `npm ci`
3. run `npx prisma migrate reset` if the schema has changed
4. run `npx prisma generate` to create required types
5. run `npm run dev`

### Pre-requisite

[Follow this guide to create your databases](./DB_SETUP.md)
Expand All @@ -18,7 +26,7 @@ Once you have complete the above guide, continue to the steps below.

## API Spec

[todo]: <Deploy and update the link below>
[todo]: # Deploy and update the link below

[Deployed API Spec](https://UPDATEME)

Expand All @@ -40,6 +48,4 @@ The users that are seeded can be used to test the API endpoints and to log into

## DATABASE ERD

[todo]: <Update this with your ERD>

TODO
211 changes: 197 additions & 14 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,131 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/posts/sorted:
get:
summary: returns a list of sorted post by recent date
tags:
- post
security:
- bearerAuth: []
responses:
"200":
description: returns a list of sorted posts by recent date
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Post"
"401":
description: fail
/posts/{id}:
put:
tags:
- post
summary: Update a post
description: This allows an authenticated user to update their post.
operationId: updatePost
security:
- bearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: integer
requestBody:
description: Post content update
required: true
content:
application/json:
schema:
type: object
properties:
content:
type: string
responses:
200:
description: Successfully updated post
content:
application/json:
schema:
$ref: '#/components/schemas/Post'
400:
description: Bad request (invalid input)
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
401:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
404:
description: Post not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

delete:
tags:
- post
summary: Delete a post
description: This allows an authenticated user to delete their post.
operationId: deletePost
security:
- bearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
200:
description: Successfully deleted post
content:
application/json:
schema:
type: object
properties:
message:
type: string
401:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
404:
description: Post not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/posts/mine:
get:
summary: Get all posts created by the authenticated user sorted by date
tags:
- post
security:
- bearerAuth: []
responses:
"200":
description: Returns a list of posts created by the logged-in user sorted by date
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Post"
"401":
description: Unauthorized


/logs:
post:
tags:
Expand Down Expand Up @@ -256,36 +381,95 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'

/cohorts:
post:
tags:
- cohort
summary: Create a cohort
description: This can only be done by the logged in user with role TEACHER.
summary: Create a new cohort and assign users
description: Creates a new cohort and assigns any users (students or teachers) to it.
operationId: createCohort
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
userIds:
type: array
items:
type: integer
description: 'Array of user IDs to assign to the cohort'
name:
type: string
description: 'Name of the created cohort'
responses:
201:
description: success
description: Cohort created successfully
content:
application/json:
schema:
type: object
properties:
status:
type: string
data:
properties:
cohort:
$ref: '#/components/schemas/Cohort'
400:
description: fail
cohort:
type: object
description: 'Created cohort object'
usersAssigned:
type: array
items:
type: integer
description: 'IDs of users assigned to the cohort'
500:
description: Internal server error

get:
tags:
- cohort
summary: Get all cohorts with their users
description: Retrieves all cohorts, including assigned users (students and teachers).
operationId: getAllCohorts
security:
- bearerAuth: []
responses:
200:
description: List of all cohorts with users
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

type: object
properties:
cohorts:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
users:
type: array
items:
type: object
properties:
id:
type: integer
email:
type: string
role:
type: string
profile:
type: object
properties:
firstName:
type: string
lastName:
type: string
500:
description: Internal server error
components:
securitySchemes:
bearerAuth:
Expand Down Expand Up @@ -430,7 +614,6 @@ components:
type: string
profileImageUrl:
type: string

CreatedUser:
type: object
properties:
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
Loading