Typescript
zely fully supports typescript. Most of tests (while development) were run with typescript. Thus, using typescript is recommended.
Using create-zely
Select Typescript Option
bash
$ npx create-zely
? Project name: my-app
? Directory: backend
? Template: typescript
$ npx create-zely
? Project name: my-app
? Directory: backend
? Template: typescript
Migrantion from Javascript
ts
import { Server } from 'zely';
module.exports.get = function(req, res) {
export function get(req: ZelyRequest, res: ZelyResponse) {
res.end("I love typescript!");
}
import { Server } from 'zely';
module.exports.get = function(req, res) {
export function get(req: ZelyRequest, res: ZelyResponse) {
res.end("I love typescript!");
}
rename zely.config.js
to zely.config.ts
ts
// zely.config.js => zely.config.ts
const { defineConfig } = require('zely');
module.exports = defineConfig({});
import { defineConfig } from 'zely';
export default defineConfig({});
// zely.config.js => zely.config.ts
const { defineConfig } = require('zely');
module.exports = defineConfig({});
import { defineConfig } from 'zely';
export default defineConfig({});