![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
RESTful API framework based on koa and bookshelf
Writing a RESTful API has never been so easy!
Koapi is a library for building RESTful APIs in a really simple way.
npm install koapi
posts
id | title | contents | created_at | updated_at |
---|---|---|---|---|
1 | Title | Contents | 2016-8-1 | 2016-8-1 |
comments
id | post_id | title | contents | created_at | updated_at |
---|---|---|---|---|---|
1 | 1 | Title | Comment | 2016-8-1 | 2016-8-1 |
const { Koapi, router, middlewares, model } = require('koapi')
const app = new Koapi();
/****************** Connect to database ******************/
model.connect({
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
})
class Comment extends model.Base {
get tableName () { return 'comments' }
get hasTimestamps () { return true }
}
class Post extends model.Base {
get tableName () { return 'posts' }
get hasTimestamps () { return true }
comments () {
return this.hasMany(Comment);
}
}
/****************** Implement Routers ******************/
const comments = router.resource(Comment, {
collection: ctx => ctx.state.parents.post.comments()
setup (route) {
// method "crud" is a shortcut for "create", "read", "update" and "destroy"
// YOU CAN ALSO USE MIDDLEWARE in "create", "read", "update", "destroy"
route.create(async(ctx, next) => {
// you can do anything before create
await next();
// you can do anything after create
})
route.read(/* You can place any middleware here if you need */{
filterable: ['created_at'], // filterable fields
sortable: ['created_at'], // sortable fields
});
route.destroy()
}
})
// POST /posts
// GET /posts
// GET /posts/:id
// PATCH /posts/:id
// DELETE /posts/:id
const posts = router.resource(Post, route => route.crud()).children(comments)
/****************** Run server ******************/
app.use(middlewares.preset('restful'))
app.use(middlewares.routers([ posts ]))
app.listen(3000);
node ./app
You have done your RESTful APIs in ONE minute
Checkout Koapp for your situation.
FAQs
RESTful API framework based on koajs
The npm package koapi receives a total of 48 weekly downloads. As such, koapi popularity was classified as not popular.
We found that koapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.