Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create node.js.yml #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
20 changes: 20 additions & 0 deletions Types/TodoTypesInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default interface TodoItem {
attachments: any[]; // You can specify the actual type for attachments if needed
collaborators: any[]; // You can specify the actual type for collaborators if needed
createdAt: string;
dependencies: any[]; // You can specify the actual type for dependencies if needed
description: string;
priority: string;
progress: number;
recurring: boolean;
status: string;
subtasks: any[]; // You can specify the actual type for subtasks if needed
tags: any[]; // You can specify the actual type for tags if needed
title: string;
todo: any[]; // You can specify the actual type for todo if needed
updatedAt: string;
user: string;
ObjectId:string;
__v: number;
_id: string;
}
57 changes: 0 additions & 57 deletions app.js

This file was deleted.

69 changes: 69 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// lib imports
import express from 'express';
// import bodyParser from 'body-parser');
import multer from 'multer';
import dotenv from "dotenv";
import cors from 'cors';
import mongoose from 'mongoose';
import session from 'express-session';
import os from 'os';

const networkInterfaces = os.networkInterfaces();
const hostAddresses: string[] = [];

// project imports
import adminRoutes from './routes/admin';
import authRoutes from './routes/auth';

const app = express();

dotenv.config({
path: "./ENV/config.env"
})

app.use(cors());
app.use(session({
secret: 'your-secret-key', // Change this to your own secret key
resave: false,
saveUninitialized: true
}));

const upload = multer(); // multer instance

app.use(upload.any()); // middleware to handle form-data
// app.use(express.urlencoded({ extended: false }));
// app.use(bodyParser.json())
// app.use(express.json())

app.use('/jarvis/auth', authRoutes);
app.use('/jarvis/admin', adminRoutes);

app.use('/', (req, res, next) => {
res.send("<h1>Welcome to todo backend </h1>")
})
mongoose
.connect(
process.env.MONGO_CONNECT_URL || ''
)
.then(result => {
app.listen(process.env.PORT, "0.0.0.0" as any);
console.log("////////////// MONGODB CONNECTED //////////////");
})
.catch(err => {
console.log(err);
});

// var host = Object.values(require('os').networkInterfaces()).reduce((r:string, list) => r.concat(list.reduce((rr:string, i) => rr.concat(i.family === 'IPv4' && !i.internal && i.address || []), [])), [])

Object.values(networkInterfaces).forEach((interfaces) => {
if(interfaces)
interfaces.forEach((iface) => {
if (iface.family === 'IPv4' && !iface.internal) {
hostAddresses.push(iface.address);
}
});
});


console.log("your localhost is : http://localhost:" + process.env.PORT+'/jarvis');
console.log("for access on other devices (on same network) : http://" + hostAddresses[0] + ":" + process.env.PORT + "/jarvis");
Loading
Loading