DEV Community

buildlogmmd
buildlogmmd

Posted on

Base TypeScript setup for a backend project

Commit 1

chore: init project with TypeScript and tsconfig
Enter fullscreen mode Exit fullscreen mode

Commands

mkdir backend && cd backend
npm init -y
npm install --save-dev typescript @types/node
npx tsc --init
mkdir src
Enter fullscreen mode Exit fullscreen mode

Update tsconfig.json

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "rootDir": "./src",
    "outDir": "./dist",
    "esModuleInterop": true,
    "strict": true
  }
}
Enter fullscreen mode Exit fullscreen mode

Create .gitignore

node_modules
dist
Enter fullscreen mode Exit fullscreen mode

Commit 2

chore: add ts-node-dev for development
Enter fullscreen mode Exit fullscreen mode

Commands

npm install --save-dev ts-node-dev
Enter fullscreen mode Exit fullscreen mode

Update package.json:

"scripts": {
  "dev": "ts-node-dev --respawn src/index.ts"
}
Enter fullscreen mode Exit fullscreen mode

Verification

Create src/index.ts:

const message: string = "TypeScript is working";
console.log(message);
Enter fullscreen mode Exit fullscreen mode

Run the development server:

npm run dev
Enter fullscreen mode Exit fullscreen mode

Expected output:

TypeScript is working
Enter fullscreen mode Exit fullscreen mode

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video 🎥

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay