Setting Up the Project
1. Creating a New Project
If you're starting a new project, follow these steps:
- Create a
srcdirectory:
mkdir srcThe src directory will contain your source files, including the index.js (or index.ts for TypeScript) file.
- Inside the
srcdirectory, create your main entry file:
touch src/index.ts- Add the code to the
index.tsfile:
import v from "vkrun"
const vkrun = v.App()
vkrun.get("/", (req: v.Request, res: v.Response) => {
res.status(200).send("Hello World!")
})
vkrun.server().listen(3000, () => {
console.log("VkrunJS started on port 3000")
})- Create
tsconfig.json:
{
"compilerOptions": {
"target": "ES2021",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"sourceMap": true,
"declaration": true
},
"exclude": ["./dist"],
"include": ["src/**/*"]
}Project Structure
Ensure your project structure follows this pattern:
my-project/
├── src/
│ └── index.ts
├── package.json
├── tsconfig.json
└── node_modules