TypeScript on NodeRun

About This Space

An example of creating server side typescript modules.


Last updated on March 24, 2020

Public Permissions:   View   Open/Fork   Run   Comment  

Server Side Typescript

You can write modules using typescript with just a couple requirements.

  • Implement your logic within the class constructor
    • This allows for the module to be "callable" from other modules.
  • Define global variables outside of the class
    • Within Profound.js, you strongly define variables using the pjs.define() API, which do not create typescript variables.
    • Typescript needs all variables to be defined in order to be compiled
  • When calling a typescript module, you must include the ".ts" file extension on the pjs.call() API.

app.js

This is a simple Profound.js module calling a server side typescript module.

  • Notice the only difference is that you must include the file extension.

hello.ts

This is a simple Hello World module. This is a rewrite of the file app.js from the "Rich Display Hello World" template.

  • Notice the constructor and global variables

webservice.ts

Here is a webservice example in Typescript

  • Again, notice the constructor and global variables

Additional Documentation

Server-side Typescript - Includes examples of importing and using other/external TS modules.

Be the first to comment:      

Comments

Write Preview Markdown: bold italic code link
Post

Filters:

Popular Recent

A demo of how to build, test and document APIs

5116

0

0

7532

0

0

CRUD Application with Detail Edit Screen

4824

0

0

fdsfdsaf a

3489

0

0

fdsafdsa

3531

0

0

Testing node.js

3055

0

0

This space shows you how to run multiple queries simultaneously by using Promise.all().

6491

0

0

A simple demo to show the recently ORM added into PJS in mid 2019.

6754

0

0

Some sample APIs

4327

0

0

This workspace shows an example of Profound API and consuming of the API within a Vue datatable

5422

0

0

A demo of how to build and consume Web Services with and without parameters

8881

0

0

Demo program CLAIM03R modified to run in NodeRun

9068

0

0