bakku / easyalert Goto Github PK
View Code? Open in Web Editor NEWA small service which allows you to send notifications from nearly anywhere
License: MIT License
A small service which allows you to send notifications from nearly anywhere
License: MIT License
Users should be able to delete their account using their token in the Authorization header.
Request:
DELETE /api/users/me
Authorization: Bearer 12345
Response:
HTTP 204
For development/testing we need some kind of mailcatcher.
When an alert is successfully sent the status and sent_at should be updated, on failure only the status should be updated.
This ticket also includes some kind of background job/worker logic so the API can enqueue mailing jobs.
Request:
POST /api/alerts
Authorization: Bearer 12345
{
"subject": "Hello!",
"message": "This is a test message"
}
Response:
HTTP 201 Created
Users should be able to update their email and password using their token in the Authorization header. It should also be possible to only update the email or only update the password.
Request:
PUT /api/users/me
Authorization: Bearer 12345
{
“email”: “[email protected]”,
“password”: “12345”
}
Response:
HTTP OK
{
"token": "12345"
}
The users table is missing indices for email
and token
.
Also the schema.sql
has to be updated.
In case a token or the password is comprimised, users should be able to refresh their token.
Request:
PUT /api/auth/refresh
Authorization: Token 12345
Response:
HTTP OK
{
“token”: “67890”
}
There are a few things that should be changed. Easyalert should be terminal-first and we probably have to save subject instead of having a name...
The http server currently sets up the postgres repositories, this should only be done in main.go
.
The admin flag is not needed. Admins can just use a database client.
Request:
GET /api/alerts
Authorization: Bearer 12345
Response:
[
{
“subject”: “Hello!”,
“status”: “sent”,
“sent_at”: “2018-01-01T01:00:00Z”,
“created_at”: “2018-01-01T00:00:00Z”
},
…
]
If no accept header is sent, easyalert will assume that the request came from a terminal.
It will then return text instead of JSON and will provide helpful curl commands for further usage
of the API.
Try to refactor the API as far as possible.
Furthermore add a ?silent
parameter so the terminal version does not produce too much output
What is needed:
Maximum budget: 10
When creating a user that already exists the API just returns:
{
"error": "User could not be created. Verify that you sent valid data."
}
A more specific error however should be returned. E.g.:
{
"error": "Email is already taken."
}
It is also possible to send a user without an email or a password. Both should be validated as well.
Alerts are the entity that contain all the information of the alert which should be sent.
Table structure:
id BIGSERIAL PRIMARY KEY
subject TEXT NOT NULL
status smallint NOT NULL
sent_at TIMESTAMP DEFAULT NULL
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE
created_at TIMESTAMP NOT NULL
updated_at TIMESTAMP NOT NULL
Implement the following endpoint:
POST /api/users/auth
{
"email": "[email protected]",
"password": "test1234"
}
Response 200
{
"token": "123456789"
}
The endpoint should check the credentials of the user and return the token of the user.
Currently the API does not return for any API endpoint Content-Type: application/json
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.