node_hackv1's People
node_hackv1's Issues
GET and Querying Users
HTTP GET request to http://localhost:8090/api/users should return all the available users.
{
“users”: [
{
“self”: “http://localhost:8090/api/members/{member_id}”,
“email”: “[email protected]”,
“first_name”: {first_name},
“last_name”: {last_name},
“batch”: “{batch}”
“faculty”: {
“self”: “http://localhost:8090/api/faculties/{faculty_id}”,
“name”: “{faculty_name}”
},
“department”: {
“self”: “http://localhost:8090/api/departments/{department_id}”,
“name”: “{department_name}”
},
“degree”: {
“self”: “http://localhost:8090/api/degrees/{degree_id}”,
“name”: “{degree_name}”
},
},
…
]
}
GET /users endpoint should handle the following query parameters.
Query Parameters
Parameter | Description |
---|---|
faculty_idGET /users?faculty_id={faculty_id} | Query users by faculty. |
department_idGET /users?department_id={department_id} | Query users by department. |
degree_idGET /users?degree_id={degree_id} | Query users by degree. |
Example :-
GET /users?department_id={department_id}&batch_id={batch_id}
Returns a list of users that are enrolled under the given department and the batch
Implement Fuzzy Search
Parameter | Description |
---|---|
GET /users?q={keyword} | keyword can include a name, email, department_name,... a combination and even part of them. |
Examples :-
‘comp sc’ > [ {Alice, Computer Science, ..}, {Bob, Computer Science, ..} ]
‘alic comp sc’ > [{Alice, Computer Science, .. }]
GET /users?q=gayan comp
{
“users”: [
{
“self”: “http://localhost:8090/api/users/{user_id}”,
“first_name”: “Gayan”,
department”: {
“self”: “http://localhost:8090/api/departments/{department_id}”,
“name”: “Computing and Information Systems”
},
...
},
…
]
}
Add beans property role to User
There are two types of roles: user
, and admin
.
If the role is not set, it should default to user
.
POST /users
Request schema 1
{
"username":"user",
"email" : "[email protected]",
"password" : "User@123"
}
Response schema 1
{
"role": "user",
"self": "http://localhost:8090/api/users/{user_id}",
"email": "[email protected]"
}
Request schema 2
{
"username":"moderator",
"email" : "[email protected]",
"password" : "Moderator@123",
"role":"moderator"
}
Response schema 2
{
"role": "moderator",
"self": "http://localhost:8090/api/users/{user_id}",
"email": "[email protected]"
}
Status 400 Return if the input is invalid (e.g. invalid role name).
Note
Placeholder {user_id} should contain an actual value (eg.UUID, Integer, String...).
Add beans property mobile to User
- Add the optional beans property ‘mobile’ to the User.
- The ‘mobile’ property be able to pass into POST /users, in addition to the userName, email and password properties.
Request schema:
{
"username": "{username}",
“email”: “{email}”,
“mobile”: “94778976377”
}
Response schema:
{
“self”: “http://localhost:8090/api/users/{user_id}”,
"userName": "{username}",
“email”: “{email}”,
“mobile”: “94778976377”
}
Validate that the mobile no. being passed in the POST /users is a valid one. Make sure the test cases, in which mobile validity is being checked do pass.
400 Bad Request: If the mobile no. is invalid (incorrectly formatted)
Note
In a POST request to http://localhost:8090/api/users, email and userName is the only required parameter.
Placeholder {email} should contain an actual value (eg. [email protected]).
Continuous Delivery
Enable automatic-deployment of one of your merged branches (master) into a PaaS. Make sure that it auto-deploys only if the Travis CI tests, do pass. Once done, comment the app url in here.
Prequestite:
Issue #15: Setup Travis
References:
https://devcenter.heroku.com/categories/deployment
Implement POST /users
HTTP POST request to http://localhost:8090/api/users should create a new user.
Request schema #1:
{
"username":"admin",
"email" : "[email protected]"
“password”: “password”
}
If the password is not set, you should randomly generate a password in the backend.
Response schemas:
Status 201: Return if the user was successfully created.
{
“self”: “http://localhost:8090/api/users/{user_id}”,
“email”: “[email protected]”
}
Status 400: Return if email is not set.
Status 409: If the user already exists.
{
"status": 409,
"message": "An user with email: {email} already exists.",
"developerMessage": "User creation failed because the email: {email} already exists."
}
Request schema #2
{
"username":"admin",
“email”: “[email protected]”
}
Here the password is not set.
Response schema
Status 201: Return if the user was successfully created.
{
“self”: “http://localhost:8090/api/users/{user_id}”
“email”: “[email protected]”
}
Note
Placeholders {email}, {user_id} should contain actual values.
It's recommended that you use UUID as the primary key.
OAuth 2.0
Users should be able authenticate against the API using the ‘password’ grant type (Resource Owner Password Flow).
Endpoint http://localhost:8090/api/oauth/token is called to request a token [access or refresh].
Request
POST /oauth/token HTTP/1.1
Host: localhost:{port}
grant_type=password
&username={user_email}
&password={user_password}
&client_id=letmehack-client
&client_secret=letmehack-secret
username: The end user's email
password: The end user's email.password
The server should reply with an access token.
Example:-
{
"access_token": "RTQ0NjJkFmQ5OTM2NDEsZTZjNGZmZjI3",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "DwOGYzYTlmM2YxOTQ5MGE3YmNmMDFkNTVl",
}
Make sure that your API always issues a token for the default global user= ‘[email protected]’, password=’password’
Implement POST & GET /departments
Prerequisite
You should complete issue #8, before you could start working on this one.
A department resource should follow the following request/response schema.
### Request schema
{
“name”: “Computer Science”,
“faculty_id”: “{faculty_id}
}
Response schemas
Status 201:
{
“self”: “http://localhost:8090/api/department/{user_id}”,
“name”: “Computer Science”,
"faculty": {
“self”: “http://localhost:8090/api/faculties/{faculty_id}”
"id": "{faculty_id}",
“name”: “{faculty_name}”
}
}
Status 409: If the department already exists.
Status 400: Return if a faculty with the given faculty_id does not exist.
HTTP GET request
HTTP GET request to http://localhost:8090/api/departments should return all the available departments.
{
“departments”: [
{
“self”: “http://localhost:8090/api/departments/{departments_id}”,
“id”: “{id}”,
“name”: “{name}”
},
…
]
}
This endpoint should also handle the following query parameters.
Query Parameters
Note
Placeholders { } here do imply actual values.
Enforce Password Policies
Passwords sent to the backend must meet the following complexity requirements.
- Use a minimum password length of 6 characters.
- Password must contain both lowercase and uppercase characters and number.
- Password must contain at least one of the following Non Alphanumeric characters from following: ~!@#$%^&*_-+=`|(){}[]:;"'<>,.?/
- Password must be hashed before save
If the password is not set, you should randomly generate a password, that meet the above complexity requirements.
Response schema
400 Bad Request: If the password complexity requirement is not met.
{
"status": 400,
"message": "Password complexity requirement not met",
"developerMessage": "User creation failed because password complexity requirement not met"
}
Send the password to the user upon registration
When a user is successfully created, the auto-generated password should be either sent to users mobile (via a SMS) or the email.
If a mobile no. is being passed in the request, and is successful, a SMS is sent.
If not, an email is sent.
You must use IdeaMart API(s), for sending the SMS.
http://www.ideamart.lk/web/idea-pro/sms-api/
Add new beans properties to User
Prerequisites: Issue #2, Issue #9
Add the following additional properties to User
first_name
last_name
faculty_id
department_id
degree_id
batch (eg:- “2012/2013”)
POST /users
Request schema:
{
“email”: “[email protected]”,
….,
“first_name”: “{first_name}”,
“last_name”: “{last_name}”,
“faculty_id”: “{faculty_id}”,
“department_id”: “{department_id}”,
“degree_id”: “{degree_id}”,
“batch”: “{batch}”
}
Status 201:
{
“self”: “http://localhost:8090/api/members/{member_id}”,
“email”: “[email protected]”,
“first_name”: {first_name},
“last_name”: {last_name},
“batch”: “{batch}”
“faculty”: {
“self”: “http://localhost:8090/api/faculties/{faculty_id}”,
“name”: “{faculty_name}”
},
“department”: {
“self”: “http://localhost:8090/api/departments/{department_id}”,
“name”: “{department_name}”
},
“degree”: {
“self”: “http://localhost:8090/api/degrees/{degree_id}”,
“name”: “{degree_name}”
},
}
Note
‘…’ implies that there could be addition properties being passed in the request.
Implement POST & GET /faculties
A faculty resource should follow the following request/response schema.
POST /faculties
Request schema
{
“name”: “Engineering”
}
Response schemas
Status 201:
{
“self”: “http://localhost:8090/api/faculties/{faculty_id}”
“name”: “Engineering”
}
Status 409: If the faculty already exists.
HTTP GET request to http://localhost:8090/api/faculties should return, all the available faculties.
{
“faculties”: [
{
“self”: “http://localhost:8090/api/faculties/{faculty_id}”,
“id”: “{id}”,
“name”: “{name}”
},
…
]
}
Get the API up and running
Build a basic RESTful API setup with any language or framework of your choosing.
The base url of the API should be:
http://localhost:8090/api
A HTTP GET request to the above url should return a 200 OK.
It is not required that you include resource classes or the controllers in the commit.
Update the README.md with basic instructions on how to build and run the API. Include dependencies if necessary.
Note
If you are to use a database, it is better that you use an embedded database like H2, HSQL for ease of configuration, and quick startup times, though it is not mandatory to use an embedded database.
If your API is supposed to run on an application server such as Tomcat, it is recommended that you use an embedded server instead, to be able to package the entire application in a single executable file and to be able to start from a standard main method.
Resources
Representational state transfer
Getting Started · Spring Boot
Getting Started - Jersey
Integrate Swagger UI
Once done, Swagger UI page should be accessible at http://localhost:8090/api/swagger-ui.html
Feel free to use one of the Swagger 2 implementations (such as SpringFox) for easier integration.
Implement POST & GET /degrees
Prerequisite
You should complete issue #9, before you could start working on this one.
Request schema
{
“name”: “B.Sc. Computer Science”
“department_id”: “{department_id}
}
Response schemas
Status 201:
{
“self”: “http://localhost:8090/api/degrees/{degree_id}”,
“name”: “B.Sc. Computer Science”,
"department": {
“self”: “http://localhost:8090/api/departments/{department_id}”,
"id": "{department_id}",
“name”: “{name}”
}
}
Status 409: If the degree already exists.
Status 400: Return if a department with the given department_id does not exist.
HTTP GET request
HTTP GET request to http://localhost:8090/api/degrees should return all available degrees.
{
“degrees”: [
{
“self”: “http://localhost:8090/api/degrees/{degree_id}”
“id”: “{id}”,
“name”: “{name}”
},
…
]
}
This endpoint should also handle the following query parameters.
Query Parameters
Setup Travis
Integrate Travis CI with this GitHub repository.
Once done, add a travis ci badge into projects README.md, to be able to see the current build status of the project.
As this being a private repository, you’d need to use https://travis-ci.com/profile instead of https://travis-ci.org to configure the hooks.
If your language or the framework is not supported, feel free to use a different continuous integration service to your liking.
References:
https://docs.travis-ci.com/user/getting-started/
https://docs.travis-ci.com/user/status-images/
Implement POST /users/bulk
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.