2

I am looking for the best practice of an project like this:

  • Angular 2 (4) client written in TypeScript
  • Node/Express backend also written in TypeScript
  • Some shared (TypeScript) models used by both client and server code.

Should client / server / shared be separated into 3 node projects? Or is it possible to have everything in one place, what tools / configuration can be used to make this happen?

0

2 Answers 2

3

Normally you'll want two folders for your client source files and your server files, but with your shared pieces it might be better to just keep them in three separate folders for later organization. It is definitely possible to keep everything in one place though if that's just your preferred route. I'd highly recommend checking out a couple node/express angular boilerplates form github such as...

Angular 2 Express Starter (angular 2 node express)

Angular Universal Starter (angular 4 node)

Angular MEAN Boilerplate (angular 2/4 node express mongodb)

to get an idea of how other people commonly set up these projects. They're also a great basis for any of your future projects.

Sign up to request clarification or add additional context in comments.

Comments

0

You can have a single repository for your project, then create a client and server directories as follows:

server/
|- src/
|- package.json
|- tsconfig.json
|- gulpfile.js
client/
|- src/
|- package.json
|- tsconfig.json
|- .angular-cli.json

For the server side, you'll need to install the following modules:

npm install --save express socket.io @types/express @types/socket.io

you can integrate some build tasks easily with your typescript code using gulp:

npm install --save-dev typescript gulp gulp-typescript

For the client side, use Angular CLI to generate your project.

You can take a look the source code of a Chat application written entirely with Typescript, using Socket.io, Node.js and Angular here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.