...
To register this as a webservice in NodeRunProfound.js Spaces, right click on that file and choose properties, and then setup the routing path.
...
Code Block | ||||
---|---|---|---|---|
| ||||
declare var pjs; declare var productsp; declare var pds; export class tsmodule3 { constructor(request: any, res: any) { pjs.defineTable("productsp", "pjstest/productsp", { read: true, keyed: true }); pjs.define("pds", { type: 'data structure', likeRec: 'products' }); var pid = request.query.pid; if (pid) { pid = Number(pid.trim()); } if (!pid || isNaN(pid)) { res.send(`Query parameter pid is required to be a number. Value sent was [${request.query.pid}]`); return; } // Using the pjs.require API allows for this file to be eligible for hotReloading let tsclass2: any = pjs.require("tsclass2.ts"); pds = tsclass2.getRecord(pid); res.status(200).json(pjs.toObject(pds)); } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
import { ts1, ts2, ts3 } from "anotherPackage"; export class tsmodule4 { constructor(request: any, response: any) { let t1:any = ts1.myFunc(request); if (ts1.isValid) { response.status(200).json(t1.result); return; } if (!ts1.isValid) { let t2:any = ts2.myFunc(request); response.status(200).json(t2.result); return; } response.status(500).send("Unknown error occurred"); } } |
...