1.1.8 • Published 3 years ago
capy-wf v1.1.8
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',
  });
}