Code Monkey home page Code Monkey logo

angular-nest-ssr-template's Introduction

Angular 16 / Nest 10 / SSR - Template

This project is a template for building websites with server-side rendering, using Angular 16 and NestJS 10 as a base.

Project Localization

The project is localized to Brazil, with currency, language and date configuration. If you want to use it in another setup/language, remember to change the <html> tag in index.html and the configuration in src/app/app.config.ts.

Angular files (frontend)

The Angular (frontend) files are in src folder.

NestJS files (backend)

The NestJS (backend) files are in server folder.

Development server

Run npm run dev:ssr for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.

Building

Run npm run build to build the project. The build artifacts will be stored in the dist/ directory. You can use dist folder alone to run your server. No need for node_modules.

Running unit tests

Run npm run test to execute the unit tests through Karma for Angular and Jest for NestJS.

Server port

The server runs on port 4200 by default for local development. You can give another port setting the PORT environment variable. Most cloud providers will set the right port for you automatically when running within containers.

API URL

API URL must be set within src/environments/environment.ts and src/environments/environment.development.ts. We assume localhost:4200/api for local development, but you need to provide the right DNS/IP and port for production (eg.: https://yourdomain.com/api). It must be done this way for server-side rendering to work. You can't use relative paths like /api.

Production running

You can use dist folder alone in your production server. And you can call node dist/server/main.js from wherever folder you are in prompt, assuming folders server and browser are siblings as they are in dist folder after build.

Example:

  • create your server folder: mkdir /opt/example
  • copy dist folder content (server and browser folders) to your server folder: cp -r dist/* /opt/example
  • run the server with port 8080: PORT=8080 node /opt/example/server/main.js

angular-nest-ssr-template's People

Contributors

hgsantana avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.