### Basic Dockerfile Example Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/full-stack/content/docker-role.md This Dockerfile sets up a Node.js environment, copies application code, installs dependencies, and defines the start command. ```dockerfile FROM node:14 WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] ``` -------------------------------- ### Example: Start Caching Proxy Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/projects/caching-server.md Example command to start the caching proxy on port 3000, forwarding requests to http://dummyjson.com. ```shell caching-proxy --port 3000 --origin http://dummyjson.com ``` -------------------------------- ### Node.js: Compare process.cwd() and __dirname Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/nodejs/content/process-cwd-vs-dirname.md Use process.cwd() to get the directory where the Node.js process was started and __dirname to get the directory of the current module. Note that these can differ depending on where the script is executed from. ```javascript console.log(process.cwd()); // /Users/username/projects/nodejs console.log(__dirname); // /Users/username/projects/nodejs/src ``` -------------------------------- ### Run Development Server Source: https://github.com/nilbuild/developer-roadmap/blob/master/readme.md Start the development server for the developer-roadmap project using the pnpm dev command. Remember to configure your environment variables by renaming .env.example to .env. ```bash pnpm dev ``` -------------------------------- ### Run Development Server Source: https://github.com/nilbuild/developer-roadmap/blob/master/contributing.md Command to start the local development server after setting up the project. ```bash pnpm dev ``` -------------------------------- ### WebSocket Server Setup with Socket.IO Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/full-stack/content/real-time-updates.md Set up a Socket.IO server to handle WebSocket connections and broadcast messages. This example assumes an existing HTTP server. ```javascript const io = require('socket.io')(server); io.on('connection', (socket) => { socket.on('chat message', (msg) => io.emit('chat message', msg)); }); ``` -------------------------------- ### Onboard Open Claw Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/roadmaps/openclaw/content/installation@2JiT8CS9PSVSfIeao29hq.md After installation, run this command to connect your first model and channel with Open Claw. ```bash openclaw onboard ``` -------------------------------- ### Application-Level Middleware in Express.js Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/nodejs/content/middleware-pattern.md Illustrates how to apply middleware to all requests or specific route patterns. The first example adds a timestamp to the request object, while the second targets requests starting with '/api'. ```javascript const app = express(); // Runs for ALL requests app.use((req, res, next) => { req.requestTime = Date.now(); next(); }); // Runs only for /api/* routes app.use('/api', (req, res, next) => { console.log('API request'); next(); }); ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/nilbuild/developer-roadmap/blob/master/contributing.md Use these commands to clone the repository and install project dependencies locally for development. ```bash git clone git@github.com:nilbuild/developer-roadmap.git --depth 1 cd developer-roadmap pnpm add @roadmapsh/editor@npm:@roadmapsh/dummy-editor -w pnpm install ``` -------------------------------- ### SQL ROW_NUMBER() Function Example Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/sql-queries/content/rank-dense-rank-row-number.md Use ROW_NUMBER() to assign a unique sequential integer to each row, starting with 1, based on the order specified in the OVER clause. Ties do not affect the uniqueness of the assigned number. ```sql SELECT id, day, amount, ROW_NUMBER() OVER (ORDER BY amount DESC) AS rowNumber FROM sales; ``` -------------------------------- ### Run Angular Development Server Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/roadmaps/angular/content/setting-up-a-new-project@EbFRcy4s6yzzIApBqU77Y.md Navigate to your project directory and start the development server. This command compiles the application and serves it locally, typically at http://localhost:4200/. ```bash cd your-project-name ng serve ``` -------------------------------- ### CI/CD Security Check with GitHub Actions Source: https://github.com/nilbuild/developer-roadmap/blob/master/src/data/question-groups/nodejs/content/npm-package-security.md Integrate security checks into your CI/CD pipeline using GitHub Actions. This example sets up Node.js, installs dependencies, runs `npm audit`, and uses the Snyk action. ```yaml # GitHub Actions example name: Security Check on: [push, pull_request] jobs: security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 with: node-version: '18' - name: Install dependencies run: npm ci - name: Run security audit run: npm audit --audit-level=high - name: Run Snyk uses: snyk/actions/node@v1.1234.0 # Use specific version tag, not master env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} ```