Deno Framework Like Spring Boot

import { Spring, Context, Middleware } from './src/spring.ts';

let app = new Spring();

function delay() {
	return new Promise((resolve, reject) => {
		setTimeout(() => {
			resolve();
		}, 500);
	});
}

app.static('public');

// app.use(async (ctx: Context, next) => {
// 	console.log('1');
// 	await delay();
// 	await next();
// 	console.log('2');
// });

// app.use(async (ctx: Context, next) => {
// 	console.log('3');
// 	await delay();
// 	await next();
// 	console.log('4');
// });

app.get('/home', async (ctx: Context) => {
	ctx.render('index.html', {
		data: {
			name: 'linweiwei',
		},
	});
	return;
});

// app.post('/api/data', async (ctx: Context, next) => {
//   ctx.response.body = `{
//       code: 0,
//       data: {},
//       msg: "success",
//     }`;
// });

// app.use(async (ctx: Context, next) => {
// 	console.log('3');
// 	ctx.response.body = '404';
// 	return;
// });

await app.listen(4000);

start app.ts

deno run --allow-run --allow-net --allow-read --unstable app.ts

Download Details:

Author: linweiwei123

Source Code: https://github.com/linweiwei123/spring.js

#deno #node #nodejs #javascript

Deno Framework Like Spring Boot
3.95 GEEK