-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove render and static method with other files
- Loading branch information
Showing
8 changed files
with
13 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,15 @@ | ||
import { WebServer } from '../../lib/core/server'; | ||
import { Context } from '../../lib/types/types'; | ||
import ejs from 'ejs'; | ||
const app = new WebServer(); | ||
|
||
// Configure the template engine | ||
app.engine('.ejs', async (path: string, options: object, callback: (err: Error | null, rendered?: string) => void) => { | ||
ejs.renderFile(path, options, callback); | ||
}); | ||
|
||
// Set default view engine and views directory | ||
app.set('view engine', '.ejs'); | ||
app.set('views', './views'); | ||
|
||
app.use(async (ctx: Context, nxt: Function) => { | ||
console.log('hello from mid'); | ||
await nxt(); | ||
}); | ||
// // Define routes | ||
app.use('/api', async (ctx: any, next: () => Promise<void>) => { | ||
// Example middleware for API routes | ||
console.log('API route accessed'); | ||
await next(); | ||
}); | ||
|
||
// Define a route with `all` method | ||
// Define a dynamic route with `all` method | ||
app.all('/about', async (ctx: Context) => { | ||
ctx.render('index'); | ||
ctx.end('REQUEST ' + ctx.method + ctx.url); | ||
}); | ||
|
||
// Start the server | ||
app.init({ | ||
port: 3000, | ||
host: 'localhost', | ||
host: '127.0.0.1', | ||
logger: true, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters