Skip to content

Commit

Permalink
Elimine todo el historial de git para asegurarme de que no hayan cont…
Browse files Browse the repository at this point in the history
…raseñas expuestas
  • Loading branch information
luciocape committed Oct 27, 2024
1 parent 241c833 commit 6e58281
Show file tree
Hide file tree
Showing 134 changed files with 8,707 additions and 8,332 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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: Deploy app Digital Ocean

on:
push:
branches: [ "master" ]

jobs:
build:

runs-on: self-hosted

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

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i
- run: npm run build --if-present
# - name: Install doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DO_TOKEN }}
# - name: Set up SSH
# run: |
# eval "$(ssh-agent -s)"
# ssh-add - < "${{ secrets.SSH_PRIVATE_KEY }}"
# - name: Deploy to Droplet
# run: |
# ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{secrets.IP_PUBLICA}}
# cd ./var/www/html/Vue
# git pull
# npm install
# pm2 restart app.js
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
dist
.DS_Store
node_modules/

# local env files
.env.*.local

.env
.env.development
# Log files
npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# web

Sitio web oficial de SugarCoach Diabetes Premium
## Project setup
```
npm install
Expand Down
8 changes: 8 additions & 0 deletions backend/ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
apps : [{
name : "sugar-web-api",
script : "index.js",
watch : true,
max_memory_restart: '1000M'
}]
}
76 changes: 76 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require('dotenv').config()
console.log("Iniciado")
async function startServer() {
try {
const port = process.env.PORT || 8080
const user = process.env.USER
const pass = process.env.PASS
const nodemailer = require('nodemailer')
const cors = require('cors')
const express = require('express')
const app = express()
app.use(express.urlencoded({extended: false}))
app.use(express.json())
// Middleware para CORS
app.use(cors({
origin: ['https://sugar.coach', 'http://localhost:8081'],
methods: ['POST'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true
}))
// POST METHOD API URL
app.get('/', (req, res) => {
res.send("Funciona!!")
})
app.post('/submit', (req, res) => {
const {username, email} = req.body
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: user,
pass: pass
}
});

const mailOptions = {
from: user,
to: user, // Aquí pones la dirección a la que quieres enviar el correo
subject: `Cuenta borrada: ${username}` ,
text: `Nombre: ${username}, Email: ${email}`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
} else {
console.log('Email enviado: ' + info.response);
}
});

res.send( `\nreq.body:\n${username} ${email}`)
// res.json({  
// message: 'Formulario enviado correctamente' });

})

app.listen(port, () => {
console.log(`Servidor escuchando en el puerto ${port}`);
});
}catch (err) {
console.error(error);
}
}
startServer()
// const nodemailer = require('nodemailer');
// const path = require('path');

// Configura Express para poder recibir datos de formularios
// app.use(express.urlencoded({ extended: false }));
// app.use(require('./routes/index'));
// app.use(express.static(path.join(__dirname, 'views')));


// Ruta para procesar el formulario
// app.post('/submit', (req, res) => {

//
// });
Loading

0 comments on commit 6e58281

Please sign in to comment.