t4t5/november-cli hiện có 51 sao trên GitHub, viết chủ yếu bằng JavaScript. ❄️ Generate a Node.js API for your Ember.js app
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
A model file (app/models/user.js) for the user, which will determine the structure of the database table
Routes in app/router.js for creating, reading, updating and deleting users (based on the conventions of Ember Data). Feel free to remove the actions you don't need.
Controller files, which hook up the routes to database actions:
app/controllers/user/add.js
app/controllers/user/list.js
app/controllers/user/load.js
app/controllers/user/update.js
app/controllers/user/remove.js
With the app and your local database running in the background, visit localhost:9000/users, and you should see:
{
"users": []
}
The table users has automatically been created in your database.
Actions
Actions are for API endpoints which are not specifically tied to any model.
$ november generate action login
This generates:
An action file (app/actions/login.js)
A route in app/router.js (POST by default)
Render()
The render()-method in your controllers is used for rendering both your models and your error messages. It takes a single argument.
Rendering models
If you pass a valid sequelize model to render(), it will generate that model according to the JSON API conventions used by Ember Data.
The most basic usage:
render(<your-sequelize-model>);
...which can also be typed like this:
render({
model: <your-sequelize-model>
});
returns:
{
"user": {
<...>
}
}
If your sequelize model includes associated models, they are sideloaded by default:
... while still showing a more descriptive error to the developer in the console so that you can locate the problem:
You can also render your own exceptions to the user, by throwing a string with the error message or an array where the first element is the error code and the second is the error message:
// app/controllers/user/update.js
req.models.user.find({
where: {
username: req.params.username
}
})
.then(function(user) {
if (user.id !== req.user) {
throw [403, "You are not allowed to edit this user!"]
}
return user.save();
})
.then(function(user) {
// Not gonna happen
})
.catch(function(err) {
render(err);
});
...what the client will see:
{
"error": {
"code": 403,
"message": "You are not allowed to edit this user!"
}
}
Todos
TDD is not really my thing, but it would be nice to get some automatic Mocha tests when you generate new models. :)
Contact
If you have any questions, feel free to ping me on Twitter or just open an issue!
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/t4t5/november-cli là nguồn chính thức.
t4t5/november-cli có những chủ đề gì?
GitHub topics của t4t5/november-cli: "database", "ember", "ember-data", "nodejs", "sequelize". TopGit xếp repo vào nhóm Data.
t4t5/november-cli có phải mã nguồn mở không?
Có — t4t5/november-cli phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/t4t5/november-cli.
t4t5/november-cli có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho t4t5/november-cli. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
t4t5/november-cli còn đang phát triển không?
Commit gần nhất trên t4t5/november-cli là 9.8 năm trước (theo timestamp GitHub). Repo có 10 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
t4t5/november-cli dùng license gì?
t4t5/november-cli phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc november-cli có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về november-cli.