
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
An API-driven framework for building nodejs apps, using MVC conventions. It only will provide a structure, inspired on Ruby on Rails, that will allow you to organise better your projects, initialise your own or third party libraries, call in a easy way your models, helpers, etc.
First install node.js and mysql. Then:
$ git clone https://github.com/zhongzhi107/kakao
$ yarn
config/index.js$ vi config/index.js
connection: {
host: process.env.MYSQL_HOST || 'localhost',
user: process.env.MYSQL_USER || 'root',
password: process.env.MYSQL_PASSWORD || '',
database: process.env.MYSQL_DATABASE || 'kakao',
port: 3306,
charset: 'utf8',
timezone: 'UTC',
// debug: true,
}
$ yarn run migrate:latest
$ yarn start
By default the app tries to connect to port 3000. After starting the application you can check it at http://localhost:3000/roles
以下是默认约定,如果不想按着默认约定编码,可以在代码中使用指定参数的方式更改
users和posts的关联表名称应该为posts_userstags和posts的关联表名称应该为posts_tagsusers和tags的关联表名称应该为tags_users被关联表名称的单数_id,如 user_id tag_id post_idkakao能根据model自动创建RESTful路由地址
import Role from '../models/roles';
import ResourceRouter from '../utils/router';
export default ResourceRouter.define(Role.collection())
上面的代码会自动创建以下路由:
| 提交方式 | 路由 | 说明 |
|---|---|---|
| POST | /roles | 新建一个角色 |
| GET | /roles | 列出所有角色 |
| GET | /roles/:id | 获取某个指定角色的信息 |
| PATCH | /roles/:id | 更新某个指定角色的信息 |
| DELETE | /roles/:id | 删除某个角色 |
import Role from '../models/role';
import ResourceRouter from '../utils/router';
const users = ResourceRouter.define({
// 假设在role model中已经设定了role和user的关联关系
collection: (ctx) => ctx.state.role.users(),
name: 'users',
setup(router) {
router
.use(async (ctx, next) => {
ctx.state.role = await Role.findById(
ctx.params.role_id,
{require: true}
);
await next();
})
.crud();
},
});
export default ResourceRouter.define({
collection: Role.collection(),
setup(router) {
router.crud();
// router.create().read().update().destroy();
// 使用嵌套路由
router.use('/roles/:role_id(\\d+)', users.routes());
},
});
上面的代码会自动创建以下路由:
| 提交方式 | 路由 | 说明 |
|---|---|---|
| POST | /roles | 新建一个角色 |
| GET | /roles | 列出所有角色 |
| GET | /roles/:id | 获取某个指定角色的信息 |
| PATCH | /roles/:id | 更新某个指定角色的信息 |
| DELETE | /roles/:id | 删除某个指定角色的信息 |
| POST | /roles/:role_id/users | 新增一个某个指定角色的用户 |
| GET | /roles/:role_id/users | 列出某个指定角色的所有用户 |
| GET | /roles/:role_id/users/:user_id | 列出某个指定角色的指定用户 |
| PATCH | /roles/:role_id/users/:user_id | 修改某个指定角色的指定用户 |
| DELETE | /roles/:role_id/users/:user_id | 删除某个指定角色的指定用户 |
...
& 前需要加 \,如 curl http://localhost/roles?sort=id\&direction=desc--globoff 参数,如 curl --globoff http://localhost/roles?where[name]=salesFAQs
Kakao is an ORM and RESTful nodejs web framework based Koa2 like Ruby on Rails.
The npm package kakao receives a total of 10 weekly downloads. As such, kakao popularity was classified as not popular.
We found that kakao 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.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.