@kwruntime/core
v2.0.23
Published
Runtime for typescript/civet, with URL imports, NPM imports, GITHUB imports, GITLAB imports and more. The fun of deno, inside node.js + civet language.
Downloads
57
Maintainers
Readme
kwruntime/core (2.x)
Major update for this project. The entire process of importing URLs, files, and other languages has been redesigned.
Features of kwruntime/core
- Allows importing URLs (in the style of Deno)
- Allows importing npm packages directly at runtime, even for ESM packages
- Built-in support for TypeScript and Civet
Getting started
For installation instructions, click here: INSTALL
kwruntime /path/to/file.civetWithin node.js
const {kwruntime} = require("@kwruntime/core")
main()
async function main(){
const axios = await kwruntime.import("npm:[email protected]")
const response = await axios("https://ipinfo.io")
console.info("Response:", response.data)
}or setting the execution to a file (similar result to how it would be executed in the terminal):
const {kwruntime} = require("@kwruntime/core")
// execute the file server.civet
kwruntime.main([process.argv[1], __dirname + "/server.civet"])Typescript and civet support
interface Person {
name: string;
age: number;
}
function greet(person: Person): string {
return "Hello, " + person.name + "!";
}
const alice: Person = {
name: "Alice",
age: 36
};
console.log(greet(alice));
You can also write in Civet:
interface Person
name: string
age: number
function greet(person: Person): string
return "Hello, " + person.name + "!"
alice: Person :=
name: "Alice"
age: 36
console.log greet aliceOutput:
kwruntime test.civet
Hello, Alice!import from NPM packages, no need to install
Example: server.civet using express
express from "npm:[email protected]"
app := express()
app.get "/", (req, res): void =>
res.send "Welcome to the kwruntime!"
app.listen 8000
console.info "Server active"And test:
curl http://127.0.0.1:8080
Welcome to the kwruntime!import from URL
express from "https://esm.sh/[email protected]"
app := express()
app.get "/", (req, res): void =>
res.send "Welcome to the kwruntime!"
app.listen 8000
console.info "Server active"WARNING: Importing from esm.sh is a bit slow at the moment. It is recommended to import using npm as in the previous example.
Si quiere ver el progreso de la compilación de archivos typescript/civet, ajuste la variable de entorno DEBUG=1
DEBUG=1 kwruntime /path/to/file
And test:
curl http://127.0.0.1:8080
Welcome to the kwruntime!