Created
August 23, 2018 20:47
-
-
Save k1r0s/8d9aa060f6f3b283f1a24f0f1e6f2a8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { AbstractResource } from "@ritley/core"; | |
| import DataService from "../services/database.service"; | |
| import { Dependency, ReqTransformBodySync } from "@ritley/decorators"; | |
| @Dependency("database", DataService) | |
| export default class UserResource extends AbstractResource { | |
| constructor(_database) { | |
| super("/users"); | |
| } | |
| @ReqTransformBodySync | |
| post(req, res) { | |
| const payload = req.body.toJSON(); | |
| this.database.create("users", payload).then(user => { | |
| res.statusCode = 200; | |
| res.end(JSON.stringify(user)); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment