Typescript support in server-side code

Hello.Does the server-side code in Monday hosting supports typescript? We’re trying to deploy a simple ExpressJS application that is written in typescript but can’t pass the deployment stage. This error always appears.


In order for the deployment to be successful, the container should be up and listen on port 8080.***

Here’s the full log:
:check_mark: Build asset to deploy
:check_mark: Preparing environment
:check_mark: Asset uploaded successfully
:multiply: There was an error deploying the application.
========== Logs ==========
Internal Monday Code API runs at http://localhost:59999

mondaycom-server@1.0.0 start
npm run build && npm run server
mondaycom-server@1.0.0 build
npx tsc
src/app.ts(1,21): error TS7016: Could not find a declaration file for
module ‘express’. ‘/workspace/node_modules/express/index.js’
implicitly has an ‘any’ type.
Try npm i --save-dev @types/express if it exists or add a new
declaration (.d.ts) file containing declare module 'express';
src/app.ts(2,24): error TS7016: Could not find a declaration file for
module ‘body-parser’. ‘/workspace/node_modules/body-parser/index.js’
implicitly has an ‘any’ type.
Try npm i --save-dev @types/body-parser if it exists or add a new
declaration (.d.ts) file containing declare module 'body-parser';
src/app.ts(16,24): error TS7006: Parameter ‘’ implicitly has an ‘any’
type.
src/app.ts(16,27): error TS7006: Parameter ‘res’ implicitly has an
‘any’ type.
src/app.ts(20,21): error TS7006: Parameter '
’ implicitly has an ‘any’
type.
src/app.ts(20,24): error TS7006: Parameter ‘res’ implicitly has an
‘any’ type.
npm notice
npm notice New major version of npm available! 10.8.2 → 11.6.3
npm notice Changelog: Release v11.6.3 · npm/cli · GitHub
npm notice To update run: npm install -g npm@11.6.3
npm notice

In order for the deployment to be successful, the container should be
up and listen on port 8080.

Then here’s on our app:import express from “express”;

import bodyParser from “body-parser”;

function getHealth() {

return {

ok: true,

message: “Healthy test”,

};

}

const app = express();

const port = 8080;

app.use(bodyParser.json());

app.get(“/”, function (_, res) {

res.json(getHealth());

});

app.get(“/health”, (_, res) => {

res.json(getHealth());

res.end();

});

app.listen(port, () =>

console.log(App listening at ``http://localhost``:${port})

);

export default app;

Then here is our package.json:
{

“name”: “mondaycom-server”,

“version”: “1.0.0”,

“description”: “”,

“license”: “ISC”,

“author”: “”,

“type”: “module”,

“main”: “build/app.js”,

“scripts”: {

"dev": "npm run stop && concurrently \\"npm run dev-server\\" \\"npm run expose\\"",

"dev-server": "npx ts-node --watch ./src/app.ts",

"start": "npm run build && npm run server",

"build": "npx tsc",

"server": "node build/app.js",

"expose": "mapps tunnel:create -p 8080",

"stop": "kill-port 8080 && kill-port 4049 && kill-port 4040",

"deploy": "npx mapps code:push"

},

“dependencies”: {

"@mondaycom/apps-sdk": "^3.2.1",

"body-parser": "^2.2.1",

"dotenv": "^17.2.3",

"express": "^5.1.0",

"typescript": "^5.9.3"

},

“devDependencies”: {

"@types/express": "^5.0.5",

"concurrently": "^9.2.1",

"cross-port-killer": "^1.4.0",

"ts-node": "^10.9.2",

"ts-node-dev": "^2.0.0"

}

}

We’ve tried to research this the whole day but can’t seem to find any documentation on how to resolve this. Even in monday apps framework documentation.

Would appreciate any response for this. Thank you.

Hey @g.agoncillo ,

Yes, you can use TypeScript for development, however the runtime is NodeJS.

It looks like your issue is that you are missing the type files or dev dependenices during your build phase. I except once you resolve the build issues, you will be able to deploy without issue.

We use GitHub actions to deploy to monday code, however it works just as well manually in the CLI.

server.ts file:

// eslint-disable-next-line no-unused-vars
import dotenv from 'dotenv';
import { Logger } from '@mondaycom/apps-sdk';
import { getSecret, isDevelopmentEnv, getEnv } from './helpers';
import app from './app';

dotenv.config();

const logTag = 'Server';
const PORT = 'PORT';
const SERVICE_TAG_URL = 'SERVICE_TAG_URL';

const logger = new Logger(logTag);
const currentPort = getSecret(PORT) || 8080; // Port must be 8080 to work with monday code
const currentUrl = getSecret(SERVICE_TAG_URL);

app.listen(currentPort, () => {
    if (isDevelopmentEnv()) {
        logger.info(`app running locally on port ${currentPort}`);
    } else {
        logger.info(JSON.stringify({ message: `up and running listening on port:${currentPort}`, server_runner: { env: getEnv(), port: currentPort, url: `https://${currentUrl}` } }));
    }
});

app.ts

import express, { NextFunction, Request, Response } from 'express';
import router from './routes/index';

const app = express();
app.use(express.json());

// add a requestId to the request object
app.use((req: Request, _res: Response, next: NextFunction) => {
    req.requestId = Math.random().toString(36);
    next();
});

app.use(router);

export default app;

package.json scripts

"scripts": {
        "start": "NODE_ENV=production node build/server.js",
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "npm run dev:stop && concurrently \"npm run dev:server\" \"npm run dev:expose\"",
        "dev:server": "nodemon src/server.ts",
        "dev:expose": "mapps tunnel:create -p 8080 -a 10340292",
        "dev:stop": "kill-port 8080",
        "fetch:schema": "bash fetch-schema.sh",
        "codegen": "graphql-codegen",
        "fetch:generate": "npm run fetch:schema && npm run codegen",
        "build": "npx tsc"
    },

You would then run the following CLI commands:

npm install
npm run build

npm i -g @mondaycom/apps-cli //optional if not already installed
mapps init -t MONDAY_API_TOKEN //optional if not already configured

mapps code:push -a APP_ID

Actually, sorry @g.agoncillo I jsut checked your script again, if you remove the 'npm run build from your start script, this should work for you.

Run the build script before npm start is called

Okay. We have resolve it upon playing it around and this is what we discovered:

  1. As shown in the error logs, most of the issues are related to the @types packages. These packages are already listed under devDependencies in our package.json. To resolve the issue temporarily, we moved the @types packages from devDependencies to dependencies, and that made it work. It appears that both the packages and their corresponding @types need to be inside the dependencies section.

    This is concerning because @types packages are typically used only during development for TypeScript, and we prefer not to include unnecessary packages in our production build. I hope the Monday team can provide clarification, as this doesn’t seem to be documented in the developer guide.

  2. It’s clear that the server-side code supports TypeScript. We also believe that the deployment process checks for a “start” script in the package.json, and if present, it becomes the primary script executed after the files are uploaded, effectively starting the server. So we think that the execution of tsc and the node script should be within a “start” script in package. However, this behavior is not mentioned anywhere in the developer guide.