rodmg / flugzeug Goto Github PK
View Code? Open in Web Editor NEWLightweight Backend Framework for Node.js
License: MIT License
Lightweight Backend Framework for Node.js
License: MIT License
# with the api command:
$ flug api
Welcome to the Flugzeug API generator
? Model name: Test
? Would you like your model to belong to User? Yes
? Controller name: Test
? API Version: v1
? Needs authentication? No
create app/models/Test.ts
create app/controllers/v1/Test.ts
# or with the controller command:
$ flug controller
Welcome to the Flugzeug Controller generator
? Controller name: Test
? Model: Test
? API Version: v1
? Needs authentication? No
? Does the model belongs to User? Yes
create app/controllers/v1/Test.ts
curl --location --request GET 'http://localhost:8888/api/v1/test' \
--header 'Accept: application/json'
TypeError: Cannot read property 'id' of undefined
at flug/app/policies/General.ts:56:32
The req.session
object is initialized in the Controller
class, so it is available for all the next middleware. filterOwner
, appendUser
, filterRoles
and isSelfUser
middlewares use it to retrieve information about the user (from the JWT). But the req.session.jwt
object is populated only when the validateJWT
middleware is used when defining the route, which is not the case when the user chooses not to use authentication during the setup.
How to reproduce
Add new route
$ flug api MyNewRoute
then
Welcome to the Flugzeug API generator
? Model name: MyNewRoute
? Would you like your model to belong to User? Yes
? Controller name: MyNewRoute
? API Version: v1
? Needs authentication? Yes
create app/models/MyNewRoute.ts
create app/controllers/v1/MyNewRoute.ts
The next file is generate MyNewRoute.ts
import {
Table,
Column,
DataType,
ForeignKey,
BelongsTo,
} from "sequelize-typescript";
import { BaseModel } from "../libraries/BaseModel";
import { User } from "./User";
@Table({
tableName: "mynewroute",
})
export class MyNewRoute extends BaseModel<MyNewRoute> {
@Column({
type: DataType.STRING,
allowNull: true,
defaultValue: null,
})
name: string;
@ForeignKey(() => User)
@Column
userId: number;
@BelongsTo(() => User)
user: User;
}
as you can see
import { BaseModel } from "../libraries/BaseModel"
use a relative path instead of
import { BaseModel } from "@/libraries/BaseModel"
This happens also with models, I didn't test for services
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.