koa-svelte is a template using Koa as backend and Svelte as frontend.
Using a degit tool, you can install this template as:
npx degit Olyno/koa-svelte my-app
Typescript support
npm i -D typescript @types/koa @types/koa-static @types/koa-send ts-nodenpm uninstall -D @babel/core @babel/node @babel/preset-envserver/index.js file to server/index.ts and make it compatible with typescript:
```diffconst PORT = 3000;
const app = new koa();
// Serve static assets app.use(serve('public'));
// Serve index.html file app.use(async (ctx, next) => { await send(ctx, 'index.html', { root: 'public' }); return next(); })
app.listen(PORT, () => console.log('> Server listening at http://localhost:' + PORT))
```
4) Replace babel-node to ts-node inside the start script in your package.json file
5) Remove unused .babelrc file
Security
npm i koa-helmet koa-protect @koa/corsserver/index.js file:
```diff
import koa from 'koa';
import send from 'koa-send';
import serve from 'koa-static';const PORT = 3000;
const app = new koa();
// Serve static assets app.use(serve('public'));
// Serve index.html file app.use(async (ctx, next) => { await send(ctx, 'index.html', { root: 'public' }); return next(); })
app.listen(PORT, () => console.log('> Server listening at http://localhost:' + PORT)) ```