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

4090

0

0

6427

0

0

CRUD Application with Detail Edit Screen

3767

0

0

fdsfdsaf a

2466

0

0

fdsafdsa

2430

0

0

fd fdsa fdsa fdsa

2320

0

0

Testing node.js

2126

0

0

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

5296

0

0

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

5608

0

0

Some sample APIs

3287

0

0

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

4413

0

0

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

7392

0

0