Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // server.ts
- import * as koa from "koa";
- import * as koaRouter from "koa-router";
- import * as bodyParser from "koa-bodyparser";
- import * as path from "path";
- import * as nunjucks from "koa-nunjucks-2";
- import * as riot from "riot";
- import * as Riot from "riot-typescript";
- import * as serve from "koa-send";
- // import * as serve from "koa-static";
- import * from "./HelloWorldTag";
- const app: koa = new koa();
- const router: koaRouter = new koaRouter();
- //app.use(serve(__dirname + '/public'));
- app.use(async function(ctx){
- await serve(ctx, ctx.path, { root: __dirname + '/public' });
- })
- /* Config Nunjucks */
- app.use(nunjucks({
- ext: 'njk',
- path: path.join(__dirname, '/views'),
- nunjucksConfig: {
- autoescape: true
- }
- }));
- router.get('/', async function(ctx:any) {
- ctx.render('index');
- });
- app.use(router.routes()).use(router.allowedMethods());
- riot.mount('*');
- app.listen(3000);
- console.log("app listening on port 3000");
- /* index.njk */
- <!DOCTYPE html>
- <html>
- <head>
- <title>Riot JS Learning !</title>
- <script type="text/javascript" src="../js/riot/riot-compiler.min"></script>
- <script type="text/javascript" src="../js/riot-typescript/riot-typescript.js"></script>
- <script type=text/javascript src="../tags/hello-world.js"></script>
- </head>
- <body>
- <h1>Hello ! It's now time to learn Riot JS ! :D</h1>
- <hello-world></hello-world>
- </body>
- </html>
- <script>
- window.onload = function(){main();}
- </script>
- /* TREE */
- test
- .vscode
- node_modules
- public
- css
- js
- riot
- riot.min.js
- riot-compiler.min.js
- riot-typescript
- riot-typescript.js
- tags
- hello-world.ts
- hello-world.js
- views
- index.njk
- package.json
- server.js
- server.ts
- tsconfig.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement