Skip to content
View TUNISIA-user's full-sized avatar
🎯
Focusing
🎯
Focusing

Block or report TUNISIA-user

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
TUNISIA-user/README.md
 
   db.articles.find({ title: { $regex: /mongodb/i } }); // Finds articles with "mongodb" in the title (case insensitive).

  .. 

 const express = require("express"); 
const app = express();
const PORT = 8000;

// In-memory storage for rooms
let rooms = {};

// Middleware to parse JSON
app.use(express.json());

// Route to create a new room
app.post("/create-room", (req, res) => {
  const { roomId } = req.body;
  if (!rooms[roomId]) {
    rooms[roomId] = [];
    res.status(200).send(`Room ${roomId} created`);
  } else {
    res.status(400).send(`Room ${roomId} already exists`);
  }
});

// Route to join a room
app.post("/join-room", (req, res) => {
  const { roomId, userId } = req.body;
  if (rooms[roomId]) {
    if (!rooms[roomId].includes(userId)) {
      rooms[roomId].push(userId);
      res.status(200).send(`User ${userId} joined room ${roomId}`);
    } else {
      res.status(400).send(`User ${userId} is already in room ${roomId}`);
    }
  } else {
    res.status(404).send(`Room ${roomId} not found`);
  }
});

// Route to list users in a room
app.get("/room/:roomId", (req, res) => {
  const { roomId } = req.params;
  if (rooms[roomId]) {
    res.status(200).json({ users: rooms[roomId] });
  } else {
    res.status(404).send(`Room ${roomId} not found`);
  }
});

// Start the server
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));


 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



  package main

import (
    "github.com/gin-gonic/gin"
    "net/http"
)

// Struct to define a simple item
type Item struct {
    ID   int    `json:"id"`
    Name string `json:"name"`
}

var items = []Item{
    {ID: 1, Name: "Item 1"},
    {ID: 2, Name: "Item 2"},
}

func main() {
    r := gin.Default()

    // GET endpoint to fetch all items
    r.GET("/items", func(c *gin.Context) {
        c.JSON(http.StatusOK, items)
    })

    // POST endpoint to create a new item
    r.POST("/items", func(c *gin.Context) {
        var newItem Item
        if err := c.ShouldBindJSON(&newItem); err != nil {
            c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
            return
        }
        items = append(items, newItem)
        c.JSON(http.StatusCreated, newItem)
    })

    // Start the server
    r.Run(":8080")
}


  

Pinned Loading

  1. flex-social-social-app flex-social-social-app Public

    This awsome Project For Social media and math question. [Flex] OPEN SOURCE PROJECT And Thing good in this Project will help you in Front-end (React) and Back-end (Node js) πŸ”₯

    JavaScript

  2. ASTRO ASTRO Public

    Forked from bholmesdev/bholmesdev

    The whiteboard guy homepage πŸ–οΈ

    Roff

  3. react-audio-player react-audio-player Public

    Forked from samhirtarif/react-audio-player

    A mobile-friendly audio player for React with a modern look and convenient usage

    TypeScript

  4. overreacted.io overreacted.io Public

    Forked from gaearon/overreacted.io

    Personal blog by Dan Abramov.

    JavaScript

  5. axios axios Public

    Forked from axios/axios

    Promise based HTTP client for the browser and node.js

    JavaScript

  6. rust-raspberrypi-OS-tutorials rust-raspberrypi-OS-tutorials Public

    Forked from rust-embedded/rust-raspberrypi-OS-tutorials

    πŸ“š Learn to write an embedded OS in Rust πŸ¦€

    Rust