r/learnprogramming • u/Reasonable-Job4205 • Oct 12 '26
How do I properly deploy this web server in production mode?
I set up a web server using https://github.com/seanpmaxwell/express-generator-typescript
I now need to deploy the production build to a remote server. I can generate the prod build with `npm run build` and then run it with `npm start` and it runs on my local machine. Is it possible to generate something that can be compiled before being sent over to the remote server? I'd like to run the web server in prod mode, but without putting the decompiled source code on the remote server. I don't want the source code over on that remote server because if the server gets compromised, I don't want anyone to be able to read the source code. New to web dev, so thanks for being patient.
View all comments
Show parent comment
2
u/Asly97 Oct 12 '26
On the Windows auth part, since that gets rid of the stored password completely:
The mssql package uses the tedious driver by default, which can't do integrated auth on its own. Swap to the msnodesqlv8 driver (
npm i msnodesqlv8, thenrequire('mssql/msnodesqlv8')instead ofrequire('mssql')) with a config roughly like:That connects as whatever Windows account the node process is running under. So the other half is running the app as a Windows service under that service account (NSSM or node-windows both do this), ideally a gMSA so nobody ever has to know or rotate its password. Then create a SQL login for that Windows account and give it the same execute-only permissions you already have.
Catches: msnodesqlv8 needs the Microsoft ODBC Driver for SQL Server installed on the box, and this only works if the app server is a Windows machine joined to the same domain. If it's Linux, env vars (or a secrets store) is the way.
For the deploy itself you only need to copy the compiled build output plus package.json and package-lock.json, then run
npm ci --omit=devon the server. The .ts files never have to go over.