hackapp-api's People
hackapp-api's Issues
Login: inconsistent naming convention
When signing up, the user passes the server firstName
and lastName
. But then, in response, the server returns first_name
and last_name
. To keep naming consistent, we should probably choose one (ideally firstName
and lastName
, since that's what the front end uses).
Initial setup
Setup the initial file hierarchy, express and database client, and net configurations.
Incorrect routes in documentation
In the documentation, it says creating a hackathon is the route /hacks/
. However, this returns a 404 Not Found
error. It appears that all admin routes have a /a/
prepended to the route. So, the correct route is /a/hacks/
. The documentation will need to be changed for most routes to reflect the prepended /a/
or /u/
.
Alternatively, you could fix the naming to align with the documentation, which is more pretty. That's a design decision I'll leave to you!
JWT admin validator
Create an JWT admin validator function that determines if a token has admin privileges.
Creating/updating hackathon ignores "draft" property
The backend ignores whether we create or update a hackathon with a "draft" property. It has draft: true
for all hackathons by default. This also needs to be reflected in documentation, and it needs to be mentioned in documentation for getting hackathons too.
Create Purchases table
Mocha test runner setup
Setup a test runner using Mocha and Docker-compose.
Initial database schema
Create Hackathons table
Incorrect return value for getHackathons route
It returns an object like the following:
{
hid: "27f99540-7039-11ea-bd77-0242ac140002",
name: "",
start_date: "2020-03-27T14:41:59.992Z",
end_date: "2020-03-27T14:41:59.992Z",
location: "",
max_reg: 100,
reg_deadline: "2020-03-27T14:41:59.992Z",
draft: true
}
start_date
should be startDate
, end_date
should be endDate
, max_reg
should be maxReg
, and reg_deadline
should be regDeadline
. You might be able to do this in your sql:
SELECT start_date AS startDate, end_date AS endDate, ...
JWT middleware
Create the fundamental JWT middleware functions necessary for request/session authentication.
Create PUT /hacks/[hack-name]
Description
Create a /hacks/[hack-name]
endpoint that handles PUT
requests to update a hackathon.
This is an admin authenticated endpoint
Request
Headers
{
token: ''
}
Arguments:
JSON Body
{
hackathonName: '',
}
Response
Code: 200
Response:
{
message: "Hackathon updated"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create GET /hacks/[hack-name]/reg/question/[qid]
Description
Create a /hacks/[hacks-name]/reg/question/[qid]
endpoint that handles GET
requests to get a registration question.
This is an admin authenticated endpoint
Request
Headers
{
token:""
}
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Got registration question",
question: {},
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create GET /users
Description
Create a /users
endpoint that handles GET
requests to get a user.
Request
Headers
{
token: ""
}
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Received user info",
user: {},
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have privileges"
}
Create PUT /org
Description
Create an /org
endpoint that handles PUT
requests to update an organization.
This is an admin authenticated endpoint
Request
Headers
{
token: ""
}
Arguments:
JSON Body
{
organizationName: "",
}
Response
Code: 200
Response:
{
message: "Organization updated"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create POST /hacks/[hack-name]/req/question
Description
Create a /hacks/[]hacks-name]/req/question
endpoint that handles POST
requests to create a new registration question.
This is an admin authenticated endpoint
Request
Headers
{
token: ''"
}
Arguments:
JSON Body
{
question: {},
}
Response
Code: 201
Response:
{
message: "Registration question created"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Wrong error: Get hackathons
I tried to GET /hacks/
, but it gives me a 404
error. This is caused by the DAL which says there are no rows to show, but this probably shouldn't be a 404
. The correct response is an empty array []
which should be loaded into the application to show that no hackathons have been created.
Create Options tables
Create Registrants table
Create Users table
Create GET /hacks
Description
Create a /hacks
endpoint that handles GET
requests to get all hackathon overviews.
Request
Headers
n/a
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Hackathons retrieved",
hackathons: []
}
Create POST /org
Description
Create an /org
endpoint that handles POST
requests to create a new organization.
This is an admin authenticated endpoint
Request
Headers
{
token: ''
}
Arguments:
JSON Body
{
organizationName: '',
}
Response
Code: 201
Response:
{
message: "Organization created"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create Txt_Answers table
Create Img_Files table
Create GET /org
Description
Create an /org
endpoint that handles GET
requests to get an organizations details.
Request
Headers
n/a
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Organization retrieved",
organizationName: ""
}
Create Txt_Files table
JWT user validator
Create a JWT user validator function that determines if a request is targeting the correct user according to its token.
Create GET /hacks/[hack-name]/reg/users/csv
Description
Create a /hacks/[hacks-name]/reg/users/csv
endpoint that handles GET
requests to get all user registration info.
This is an admin authenticated endpoint
Request
Headers
{
token:""
}
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Registration info",
regInfo: [],
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create DELETE /hacks/[hack-name]/reg/question/[qid]
Description
Create a /hacks/[hacks-name]/reg/question/[qid]
endpoint that handles DELETE
requests to delete a registration question.
This is an admin authenticated endpoint
Request
Headers
{
token:""
}
Arguments:
n/
Response
Code: 200
Response:
{
message: "Deleted question"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
BUG: CORS preflight bug when trying to connect to server
When attempting to connect to the server, web browsers perform a CORS preflight test to see if it has access permissions on the server. However, no OK status is sent in response in the current code. Change config.js
to the following:
AccessControl(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header(
'Access-Control-Allow-Methods',
'GET, POST, PUT, DELETE'
);
res.header(
'Access-Control-Allow-Headers',
'X-Requested-With, content-type, x-access-token'
);
res.header('Access-Control-Allow-Credentials', true);
if ('OPTIONS' === req.method) {
res.sendStatus(200);
}
if (process.env.PROD) {
console.log(`${req.ip} ${req.method} ${req.url}`);
}
next();
},
...
};
Initial endpoints
Create initial endpoints and handlers with no business logic - return dummy data.
Unexpected return value for POST hackathon request
Expected:
{
"hid": "string",
"name": "string",
"startDate": 0,
"endDate": 0,
"location": "string",
"maxReg": 0,
"regDeadline": 0
}
Received:
"hack": {
"hack": {
"hid": "string",
"name": "string",
"start_date": 0,
"end_date": 0,
"location": "string",
"max_reg": 0,
"reg_deadline": 0
}
}
Illegal header: ha-api-token
Create GET /hacks/[hack-name]/details
Description
Create a /hacks/[]hacks-name]/details
endpoint that handles GET
requests to get hackathon details.
Request
Headers
n/a
Arguments:
n/a
Response
Code: 201
Response:
{
message: "Hackathon details received",
details: {},
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Create POST /Hacks/[hack-name]/details
Description
Create a /hacks/[]hacks-name]/details
endpoint that handles POST
requests to create new hackathon details.
This is an admin authenticated endpoint
Request
Headers
{
token: ''"
}
Arguments:
JSON Body
{
hackathonDetails: {},
}
Response
Code: 201
Response:
{
message: "Hackathon details created"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create DELETE /users
Description
Create a /users
endpoint that handles DELETE
requests to delete a user.
Request
Headers
{
token: ""
}
Arguments:
n/a
Response
Code: 200
Response:
{
message: "Deleted user",
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have privileges"
}
Create Files_Links table
Create Radio_Answers table
JWT decoder
Create a JWT decoder function
BUG: No response received if try to sign in with a non-existant user
Postman hangs with no response when trying to make a sign-in request
hackapp-api | (node:29) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uid' of undefined
hackapp-api | at signIn (/usr/src/app/src/handlers/auth.js:121:47)
hackapp-api | at <anonymous>
hackapp-api | at process._tickCallback (internal/process/next_tick.js:189:7)
hackapp-api | (node:29) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
hackapp-api | (node:29) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Create PUT /users
Description
Create a /users
endpoint that handles PUT
requests to update a user.
Request
Headers
{
token: ""
}
Arguments:
JSON Body
{
user: {},
}
Response
Code: 201
Response:
{
message: "Updated user info",
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have privileges"
}
Create PUT /hacks/[hack-name]/details
Description
Create a /hacks/[]hacks-name]/details
endpoint that handles PUT
requests to update hackathon details.
This is an admin authenticated endpoint
Request
Headers
{
token: ''"
}
Arguments:
JSON Body
{
details: {},
}
Response
Code: 201
Response:
{
message: "Hackathon details updated"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
JWT session/token validator
Create a JWT session/token validator that determines if a token is present in a requests header, and if so, whether it is valid.
Create DELETE /hacks/[hack-name]
Description
Create a /hacks/[hack-name]
endpoint that handles DELETE
requests to delete a hackathon.
This is an admin authenticated endpoint
Request
Headers
{
token: ''
}
Arguments:
JSON Body
{
hackathonName: '',
}
Response
Code: 200
Response:
{
message: "Hackathon deleted"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
JWT encoder
Create a JWT encoder function.
Create Questions table
Create CB_Answers table
Create PUT /hacks/[hacks-name]/reg/question/[qid]
Description
Create a /hacks/[hacks-name]/reg/question/[qid]
endpoint that handles PUT
requests to update a registration question.
This is an admin authenticated endpoint
Request
Headers
{
token:""
}
Arguments:
JSON Body
{
question: {},
}
Response
Code: 201
Response:
{
message: "Question updated"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create POST /hacks/[hack-name]
Description
Create a /hacks/[]hacks-name]
endpoint that handles POST
requests to create a new hackathon.
This is an admin authenticated endpoint
Request
Headers
{
token: ''"
}
Arguments:
JSON Body
{
hackathonName: '',
}
Response
Code: 201
Response:
{
message: "Hackathon created"
}
Code: 400
Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Create GET /hacks/[hack-name]
Description
Create a /hacks/[hack-name]
endpoint that handles GET
requests to get a hackathon.
This is an admin authenticated endpoint
Request
Headers
{
token: ''
}
Arguments:
JSON Body
{
hackathonName: '',
}
Response
Code: 200
Response:
{
message: "Hackathon retrieved",
hackathon: {},
}
Code: 400
*Response:
{
message: "Invalid syntax"
}
Code: 401
Response:
{
message: "JWT not found in header"
}
Code: 403
Response:
{
message: "Provided JWT does not have admin privileges"
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.