kitesjs / kites Goto Github PK
View Code? Open in Web Editor NEWTemplate-based Web Application Framework
Home Page: https://kitesjs.github.io/kites
License: MIT License
Template-based Web Application Framework
Home Page: https://kitesjs.github.io/kites
License: MIT License
The HttpContext property allow us to access the current request, response and user with ease.
HttpContext
in controllers derived from BaseHttpController
or @Inject
decorator.When the application grows, it is hard to manually test a behavior of each API endpoint. The end-to-end tests help us to make sure that everything is working correctly and fits project requirements.
TODO:
@kites/testing
to support end to end testingExample:
import { KitesInstance } from '@kites/core';
import { Test } from '@kites/testing';
import * as request from 'supertest';
import { TodoController } from './todo.controller';
import { TodoService } from './todo.service';
describe('Todo e2e', () => {
let app: KitesInstance;
let todoService = { findAll: () => ['list all tasks'] };
beforeAll(async () => {
app = await Test.createApp({
providers: [TodoService],
}).init();
});
it(`/GET list`, () => {
return request(app.express.app)
.get('/api/todo')
.expect(200)
.expect({
data: todoService.findAll(),
});
});
afterAll(async () => {
await app.close();
});
});
close
to close kites applicationevents
with rxjs
Example:
// close application
await kites.close();
Add new api .discover(boolean | [{path, level, ...options}])
to discover extension in directory tree
Options:
kites.config.js
in kites.options.appPath
import {engine} from '@kites/core';
async function bootstrap() {
// let kites autodiscover the extensions
const app = await engine().discover(true).init();
app.logger.info('A new kites started!');
}
bootstrap();
OR
import {engine} from '@kites/core';
async function bootstrap() {
// let kites autodiscover the extensions
const app = await engine().discover([true, 2, '/path1', '/path2']).init();
app.logger.info('A new kites started!');
}
bootstrap();
kites.config.ts
for core packagesExample:
import {once} from '@kites/common';
// wait ready event from kites instance
await once(kites, 'ready');
List action results.
Example:
@Controller("/todo")
class ToDoController extends BaseApiController {
@Get("/:task")
public async info() {
return this.ok("foo");
}
@Get("/")
public async list() {
const content = { foo: "bar" };
const statusCode = 403;
return this.json(content, statusCode);
}
Trying to implement DI System
for Kites.
Example:
Extension({
controllers: [],
views: []
})
class TodoExtension {
constructor(@Inject(TodoService) svTodo: TodoService,) {
// callable injected service here
this.svTodo.begin(task);
}
}
Example:
import {Injectable, Inject} from '@kites/common';
import {KITES_INSTANCE, KitesInstance} from '@kites/core';
@Injectable()
class TodoService {
constructor(
@Inject(KITES_INSTANCE ) private kites: KitesInstance,
) {
this.kites.logger.info('Injected kites instance!!');
}
}
Goal: People install and use kites.js easily
Build admin panel as an extension of kites. #kites-admin
First implement will use React?
Extensions have own their controllers
and views
for micro frontend.
Example:
Extension({
prefix: 'api/v1', // api route prefix
controllers: [
`./controllers/todo.controller`,
`./controllers/user.controller`,
],
views: [
`./pages/user`,
`./pages/dashboard`
]
})
class TodoExtension {}
Output:
User
and Dashboard
Wanted the list of cli tools:
mvc
: Assembling all into complete ship (default), documentbasic
: Template for building from scratchapidoc
: Template for API Documentation, nodevn/kites-apidocexpress
: Template for Express Applicationrestful
: Template for generating a RESTful API Serverspa
: Template for generating a Single Page Application (kites/spa)cms
: Template for generating a Content Management System (CMS)chat
: Template for generating a Chat applicationchatbot
: Template for generating an AI Chatbot application, vntk/chatbot, documentvideocall
: Template for generating a Video Call applicationelectron
: Template for creating a desktop application with native_modules
gateway
: Template for creating a microservices API Gatewayoauth|oauth2
: Template for creating an OAuth2 Servercrawler
: Template for crawl news, products, ...Syntax:
kites init [my_app_name] --template chatbot
Example:
kites init my_kute_chatbot --template chatbot
Then a new project will be generated at the current directory.
Example:
@Controller("/")
class ExampleController extends BaseApiController {
@Get("/")
public async info() {
return this.ok("foo");
}
Stat file folder without permission then we got an error:
2019-10-01T00:04:26.461Z [kites] info: Initializing [email protected] in mode "development", using configuration file kites.config.json
2019-10-01T00:04:26.470Z [kites] info: Searching for available extensions in E:\Projects\roomrtc\roomrtc-ce
2019-10-01T00:04:26.475Z [kites] info: Skipping extensions location cache when NODE_ENV=development or when option extensionsLocationCache === false, crawling now!
(node:8828) UnhandledPromiseRejectionWarning: Error: UNKNOWN: unknown error, stat 'E:\Projects\roomrtc\roomrtc-ce\node_modules\.bin\clang-apply-replacements'
at Object.statSync (fs.js:855:3)
at readFiles (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\fs.js:113:24)
at readFiles (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\fs.js:115:38)
at readFiles (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\fs.js:115:38)
at Object.walkSyncLevel (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\fs.js:128:36)
at Object.get (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\location-cache.js:22:21)
at Object.discover (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\discover.js:26:35)
at ExtensionsManager.init (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\extensions\extensions-manager.js:75:47)
at KitesInstance.init (E:\Projects\roomrtc\roomrtc-ce\node_modules\@kites\core\engine\kites-instance.js:179:38)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
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.