capy-wf
v1.1.8
Published
[![wakatime](https://wakatime.com/badge/user/81d95bac-b8dd-495f-a6ea-b03daa3dc2ca/project/d6d935bb-3097-4066-a98f-e5a7684afa45.svg)](https://wakatime.com/badge/user/81d95bac-b8dd-495f-a6ea-b03daa3dc2ca/project/d6d935bb-3097-4066-a98f-e5a7684afa45)
Downloads
5
Readme
cwf
The WIP web framework created to be used by j4ce.
Currently TypeScript only!
Setup Guide
- Create an npm project.
- Setup the folders more or less like this
📦The Main Folder
┣ 📂components
┃ ┗ 📜Xyz.cwf
┣ 📂src
┃ ┗ 📜index.ts
┣ 📂views
┃ ┣ 📂api
┃ ┃ ┗ 📜test.ts
┃ ┗ 📜index.cwf
┣ 📜package-lock.json
┗ 📜package.json
- The index.ts file should look like this
import { cwf } from 'capy-wf';
const app = cwf({
debug: true,
});
app.listen();
- Install ts-node-dev
npm i --save-dev ts-node-dev
- Add a dev script to the package.json file
"dev": "ts-node-dev ./src/index.ts"
- Run it!
npm run dev
Api Example
Put the file in views/api/{apiName}.ts
Should look like this:
import { ApiContext } from 'capy-wf';
export default async function (ctx: ApiContext) {
console.log(`Got: ${ctx.method}`);
ctx.sendJson({
hello: 'world',
});
}