Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Universal server API requesting

I just migrated my application to Angular 6 + Universal. It`s great but I have 2 issues to fix. Please help me for both ones:

1- How can I run the Angular Universal app in --watch mode for developing time? Before that I opened 2 terminal. In one of them I wrote command: nodemon server.js and in another on : ng build --watch. In this situation I was developing my application fast by real-time editing.

But now after each edit I use command npm run build:ssr. I takes lots of time. There should be another way for increase developing time in Angular Universal?!

2- The other issue is before I migrate to Angular Universal, I was using express to for server side same as now. I have called an API handler file like this:

const api = require('./routes/api');
app.use('/api', api);

How can I do this in new angular universal package like before in server.ts file?

like image 563
Abdol Seed Avatar asked Jul 27 '26 13:07

Abdol Seed


1 Answers

For Angular7 run npm run ssr:watch

package.json

    "ssr:watch": "run-p ssr:universal:build:*",
    "ssr:universal:build:browser": "ng run universal-demo:build --watch",
    "ssr:universal:build:server": "node ./node_modules/npm-delay 12000 && ng run universal-demo:server --watch",
    "ssr:universal:build:webpack": "node ./node_modules/npm-delay 20000 && webpack --config webpack.config.js --watch",
    "ssr:universal:build:nodemon": "node ./node_modules/npm-delay 25000 && nodemon --inspect server.js",
like image 154
gorniv Avatar answered Jul 29 '26 03:07

gorniv