Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titlestarttsmodule3.jsts
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
languagejs
titlestarttsmodule4.jsts
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");
    }
}

...