avatarciao 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,96 @@
1
+ const express = require("express")
2
+ const mongoose = require("mongoose")
3
+
4
+ const app = express()
5
+ app.use(express.json())
6
+
7
+ mongoose.connect("mongodb://127.0.0.1:27017/eventDB")
8
+
9
+ const eventSchema = new mongoose.Schema(
10
+ {
11
+ eventName: {
12
+ type: String,
13
+ required: true,
14
+ minlength: 3,
15
+ maxlength: 50,
16
+ trim: true
17
+ },
18
+ date: {
19
+ type: Date,
20
+ required: true,
21
+ validate: v => v > new Date()
22
+ },
23
+ venue: {
24
+ type: String,
25
+ required: true
26
+ },
27
+ participants: {
28
+ type: [String],
29
+ validate: v => v.length > 0
30
+ },
31
+ ticketPrice: {
32
+ type: Number,
33
+ required: true,
34
+ min: 1,
35
+ max: 9999
36
+ }
37
+ },
38
+ { timestamps: true }
39
+ )
40
+
41
+ eventSchema.pre("save", function (next) {
42
+ this.eventName = this.eventName
43
+ .split(" ")
44
+ .map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
45
+ .join(" ")
46
+ next()
47
+ })
48
+
49
+ eventSchema.post("save", function () {
50
+ console.log("Event added successfully.")
51
+ })
52
+
53
+ const Event = mongoose.model("Event", eventSchema)
54
+
55
+ app.post("/events", async (req, res) => {
56
+ try {
57
+ const event = new Event(req.body)
58
+ await event.save()
59
+ res.status(201).json(event)
60
+ } catch (err) {
61
+ res.status(400).json({ error: err.message })
62
+ }
63
+ })
64
+
65
+ app.get("/events", async (req, res) => {
66
+ const events = await Event.find()
67
+ res.json(events)
68
+ })
69
+
70
+ app.get("/events/:id", async (req, res) => {
71
+ const event = await Event.findById(req.params.id)
72
+ if (!event) return res.status(404).json({ message: "Not found" })
73
+ res.json(event)
74
+ })
75
+
76
+ app.put("/events/:id", async (req, res) => {
77
+ const event = await Event.findByIdAndUpdate(req.params.id, req.body, {
78
+ new: true,
79
+ runValidators: true
80
+ })
81
+ if (!event) return res.status(404).json({ message: "Not found" })
82
+ res.json(event)
83
+ })
84
+
85
+ app.delete("/events/:id", async (req, res) => {
86
+ const event = await Event.findByIdAndDelete(req.params.id)
87
+ if (!event) return res.status(404).json({ message: "Not found" })
88
+ res.json({ message: "Deleted" })
89
+ })
90
+
91
+ app.get("/events/venue/:venue", async (req, res) => {
92
+ const events = await Event.find({ venue: req.params.venue })
93
+ res.json(events)
94
+ })
95
+
96
+ app.listen(3000)
@@ -0,0 +1,107 @@
1
+ const express = require('express')
2
+ const multer = require('multer')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const app = express()
7
+ const port = 3000
8
+
9
+ app.use('/uploads', express.static('uploads'))
10
+
11
+ const ensureDir = dir => {
12
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
13
+ }
14
+
15
+ const storage = multer.diskStorage({
16
+ destination: (req, file, cb) => {
17
+ const { userId } = req.params
18
+ let base = 'uploads/others'
19
+ if (file.fieldname === 'profilePic') base = 'uploads/profile_pics'
20
+ if (file.fieldname === 'docs') base = 'uploads/documents'
21
+ const finalPath = path.join(base, userId)
22
+ ensureDir(finalPath)
23
+ cb(null, finalPath)
24
+ },
25
+ filename: (req, file, cb) => {
26
+ const { userId } = req.params
27
+ cb(null, `${file.fieldname}-${userId}-${Date.now()}-${file.originalname}`)
28
+ }
29
+ })
30
+
31
+ const fileFilter = (req, file, cb) => {
32
+ const allowed = /jpg|jpeg|png|pdf|docx/
33
+ const ext = allowed.test(path.extname(file.originalname).toLowerCase())
34
+ const mime = allowed.test(file.mimetype)
35
+ ext && mime ? cb(null, true) : cb(new Error('Invalid file type'))
36
+ }
37
+
38
+ const upload = multer({
39
+ storage,
40
+ fileFilter,
41
+ limits: { fileSize: 5 * 1024 * 1024 }
42
+ }).fields([
43
+ { name: 'profilePic', maxCount: 1 },
44
+ { name: 'docs', maxCount: 5 },
45
+ { name: 'others', maxCount: 5 }
46
+ ])
47
+
48
+ app.post('/upload/:userId', (req, res) => {
49
+ upload(req, res, err => {
50
+ if (err) {
51
+ return res.status(400).json({ error: err.message })
52
+ }
53
+
54
+ const result = {
55
+ profilePic: req.files.profilePic?.[0]?.path || null,
56
+ docs: req.files.docs?.map(f => f.path) || [],
57
+ others: req.files.others?.map(f => f.path) || []
58
+ }
59
+
60
+ res.json({
61
+ message: 'Files uploaded successfully!',
62
+ uploaded: result
63
+ })
64
+ })
65
+ })
66
+
67
+ app.get('/files/:userId', (req, res) => {
68
+ const { userId } = req.params
69
+ const bases = ['uploads/profile_pics', 'uploads/documents', 'uploads/others']
70
+ let files = []
71
+
72
+ bases.forEach(base => {
73
+ const dir = path.join(base, userId)
74
+ if (fs.existsSync(dir)) {
75
+ fs.readdirSync(dir).forEach(f => {
76
+ files.push(path.join(dir, f))
77
+ })
78
+ }
79
+ })
80
+
81
+ res.json({ userId, files })
82
+ })
83
+
84
+ app.delete('/delete/:userId/:filename', (req, res) => {
85
+ const { userId, filename } = req.params
86
+ const bases = ['uploads/profile_pics', 'uploads/documents', 'uploads/others']
87
+ let found = false
88
+
89
+ for (const base of bases) {
90
+ const filePath = path.join(base, userId, filename)
91
+ if (fs.existsSync(filePath)) {
92
+ fs.unlinkSync(filePath)
93
+ found = true
94
+ break
95
+ }
96
+ }
97
+
98
+ if (!found) {
99
+ return res.status(404).json({ error: 'File not found' })
100
+ }
101
+
102
+ res.json({ message: 'File deleted successfully!' })
103
+ })
104
+
105
+ app.listen(port, () => {
106
+ console.log(`FileManager running on port ${port}`)
107
+ })
@@ -0,0 +1,53 @@
1
+ const express = require('express')
2
+ const multer = require('multer')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const app = express()
7
+ const port = 3000
8
+
9
+ const uploadDir = './uploads/products'
10
+ if (!fs.existsSync(uploadDir)) {
11
+ fs.mkdirSync(uploadDir, { recursive: true })
12
+ }
13
+
14
+ const storage = multer.diskStorage({
15
+ destination: (req, file, cb) => {
16
+ cb(null, uploadDir)
17
+ },
18
+ filename: (req, file, cb) => {
19
+ cb(null, Date.now() + path.extname(file.originalname))
20
+ }
21
+ })
22
+
23
+ const fileFilter = (req, file, cb) => {
24
+ const allowed = /jpg|jpeg|png/
25
+ const ext = allowed.test(path.extname(file.originalname).toLowerCase())
26
+ const mime = allowed.test(file.mimetype)
27
+ ext && mime ? cb(null, true) : cb(new Error('Only JPG and PNG files are allowed'))
28
+ }
29
+
30
+ const upload = multer({
31
+ storage,
32
+ fileFilter,
33
+ limits: { fileSize: 2 * 1024 * 1024 }
34
+ }).single('productImage')
35
+
36
+ app.post('/upload', (req, res) => {
37
+ upload(req, res, err => {
38
+ if (err) {
39
+ return res.status(400).json({ error: err.message })
40
+ }
41
+ if (!req.file) {
42
+ return res.status(400).json({ error: 'No file uploaded' })
43
+ }
44
+ res.status(200).json({
45
+ path: req.file.path,
46
+ size: req.file.size
47
+ })
48
+ })
49
+ })
50
+
51
+ app.listen(port, () => {
52
+ console.log(`Server running on port ${port}`)
53
+ })
@@ -0,0 +1,77 @@
1
+ const express = require('express')
2
+ const multer = require('multer')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const app = express()
7
+ const port = 3000
8
+
9
+ app.use(express.urlencoded({ extended: true }))
10
+ app.use(express.json())
11
+
12
+ const uploadDir = './uploads/resumes'
13
+ if (!fs.existsSync(uploadDir)) {
14
+ fs.mkdirSync(uploadDir, { recursive: true })
15
+ }
16
+
17
+ const dbFile = './data.json'
18
+ if (!fs.existsSync(dbFile)) {
19
+ fs.writeFileSync(dbFile, JSON.stringify([]))
20
+ }
21
+
22
+ const storage = multer.diskStorage({
23
+ destination: (req, file, cb) => {
24
+ cb(null, uploadDir)
25
+ },
26
+ filename: (req, file, cb) => {
27
+ cb(null, Date.now() + path.extname(file.originalname))
28
+ }
29
+ })
30
+
31
+ const fileFilter = (req, file, cb) => {
32
+ file.mimetype === 'application/pdf'
33
+ ? cb(null, true)
34
+ : cb(new Error('Only PDF files allowed'))
35
+ }
36
+
37
+ const upload = multer({
38
+ storage,
39
+ fileFilter
40
+ }).single('resume')
41
+
42
+ app.post('/apply', (req, res) => {
43
+ upload(req, res, err => {
44
+ if (err) {
45
+ return res.status(400).json({ error: err.message })
46
+ }
47
+
48
+ const { name, email, phone } = req.body
49
+
50
+ if (!name || !email || !phone || !req.file) {
51
+ return res.status(400).json({ error: 'All fields required' })
52
+ }
53
+
54
+ const record = {
55
+ name,
56
+ email,
57
+ phone,
58
+ resume: {
59
+ filename: req.file.filename,
60
+ path: req.file.path
61
+ }
62
+ }
63
+
64
+ const data = JSON.parse(fs.readFileSync(dbFile))
65
+ data.push(record)
66
+ fs.writeFileSync(dbFile, JSON.stringify(data, null, 2))
67
+
68
+ res.status(200).json({
69
+ message: 'Application submitted successfully',
70
+ data: record
71
+ })
72
+ })
73
+ })
74
+
75
+ app.listen(port, () => {
76
+ console.log(`Server running on port ${port}`)
77
+ })
@@ -0,0 +1,52 @@
1
+ const express = require('express')
2
+ const multer = require('multer')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const app = express()
7
+ const port = 3000
8
+
9
+ const uploadDir = './uploads/gallery'
10
+ if (!fs.existsSync(uploadDir)) {
11
+ fs.mkdirSync(uploadDir, { recursive: true })
12
+ }
13
+
14
+ const storage = multer.diskStorage({
15
+ destination: (req, file, cb) => {
16
+ cb(null, uploadDir)
17
+ },
18
+ filename: (req, file, cb) => {
19
+ cb(null, Date.now() + '-' + Math.round(Math.random() * 1e9) + path.extname(file.originalname))
20
+ }
21
+ })
22
+
23
+ const fileFilter = (req, file, cb) => {
24
+ const allowed = /jpg|jpeg|png/
25
+ const ext = allowed.test(path.extname(file.originalname).toLowerCase())
26
+ const mime = allowed.test(file.mimetype)
27
+ ext && mime ? cb(null, true) : cb(new Error('Invalid file type'))
28
+ }
29
+
30
+ const upload = multer({
31
+ storage,
32
+ fileFilter,
33
+ limits: { files: 5 }
34
+ }).array('images', 5)
35
+
36
+ app.post('/upload', (req, res) => {
37
+ upload(req, res, err => {
38
+ if (err) {
39
+ return res.status(400).json({ error: err.message })
40
+ }
41
+ if (!req.files || req.files.length === 0) {
42
+ return res.status(400).json({ error: 'No files uploaded' })
43
+ }
44
+ res.json({
45
+ files: req.files.map(file => file.filename)
46
+ })
47
+ })
48
+ })
49
+
50
+ app.listen(port, () => {
51
+ console.log(`Server running on port ${port}`)
52
+ })
@@ -0,0 +1,58 @@
1
+ const express = require('express');
2
+ const multer = require('multer');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ const app = express();
7
+ const port = 3000;
8
+
9
+ const uploadDir = './uploads';
10
+ if (!fs.existsSync(uploadDir)) {
11
+ fs.mkdirSync(uploadDir);
12
+ }
13
+
14
+ const storage = multer.diskStorage({
15
+ destination: (req, file, cb) => {
16
+ cb(null, 'uploads/');
17
+ },
18
+ filename: (req, file, cb) => {
19
+ cb(null, Date.now() + path.extname(file.originalname));
20
+ }
21
+ });
22
+
23
+ const fileFilter = (req, file, cb) => {
24
+ const allowedTypes = /jpeg|jpg|png/;
25
+ const extname = allowedTypes.test(path.extname(file.originalname).toLowerCase());
26
+ const mimetype = allowedTypes.test(file.mimetype);
27
+
28
+ if (extname && mimetype) {
29
+ return cb(null, true);
30
+ } else {
31
+ cb(new Error('Only .jpg and .png files are allowed!'));
32
+ }
33
+ };
34
+
35
+ const upload = multer({
36
+ storage: storage,
37
+ fileFilter: fileFilter
38
+ }).single('profilePic');
39
+
40
+ app.post('/upload', (req, res) => {
41
+ upload(req, res, (err) => {
42
+ if (err) {
43
+ return res.status(400).json({ error: err.message });
44
+ }
45
+ if (!req.file) {
46
+ return res.status(400).json({ error: 'Please select a file to upload' });
47
+ }
48
+ res.status(200).json({
49
+ message: 'File uploaded successfully',
50
+ filename: req.file.filename,
51
+ path: req.file.path
52
+ });
53
+ });
54
+ });
55
+
56
+ app.listen(port, () => {
57
+ console.log(`Server running at http://localhost:${port}`);
58
+ });
@@ -0,0 +1,20 @@
1
+ const express = require('express');
2
+ const app = express();
3
+
4
+ const users = [
5
+ { id: '101', name: 'Alice', age: 25 },
6
+ { id: '102', name: 'Bob', age: 30 },
7
+ { id: '103', name: 'Charlie', age: 22 }
8
+ ];
9
+
10
+ app.get('/user/:id', (req, res) => {
11
+ const user = users.find(u => u.id === req.params.id);
12
+
13
+ if (!user) {
14
+ return res.status(404).json({ message: "User not found" });
15
+ }
16
+
17
+ res.json(user);
18
+ });
19
+
20
+ app.listen(3000);
@@ -0,0 +1,18 @@
1
+ const express = require('express');
2
+ const path = require('path');
3
+
4
+ const app = express();
5
+
6
+ app.get('/services', (req, res) => {
7
+ res.sendFile(path.join(__dirname, 'pages', 'services.html'));
8
+ });
9
+
10
+ app.get('/contact', (req, res) => {
11
+ res.sendFile(path.join(__dirname, 'pages', 'contact.html'));
12
+ });
13
+
14
+ app.get('/about', (req, res) => {
15
+ res.sendFile(path.join(__dirname, 'pages', 'about.html'));
16
+ });
17
+
18
+ app.listen(3000);
package/keys/all.txt ADDED
@@ -0,0 +1,36 @@
1
+ SB
2
+ $env:GEMINI_API_KEY="AIzaSyBj6soMoQbFxvGTd7ZR0MmUa9EpOTna7bc"
3
+ $env:GEMINI_API_KEY="AIzaSyCaTbOgz3COaJZgyVaPbRbhbHux8JhOANU"
4
+ $env:GEMINI_API_KEY="AIzaSyBqFbLDq7I_MN0a_sjy20dxC8cfT5hELIk"
5
+ $env:GEMINI_API_KEY="AIzaSyAtsMYrB5VHprN15R9VflHOSYX2Vo7Bjfo"
6
+ $env:GEMINI_API_KEY="AIzaSyBSO2XorXlgyb3SSgPOz5l4Q82tk1QqvAk"
7
+
8
+ jK
9
+ $env:GEMINI_API_KEY="AIzaSyB1YGMQ9GbEQiwdLKQuMz2bkX5rVKQ75YI"
10
+ $env:GEMINI_API_KEY="AIzaSyBbQC2JXD3Rf5m5zCDb2SiKlu1Iew26olE"
11
+ $env:GEMINI_API_KEY="AIzaSyD--Hr9Pej-xmoZzJ91MkaYBsyDn4O6dW8"
12
+
13
+ BC
14
+ $env:GEMINI_API_KEY="AIzaSyANwM9KVK6QeE_dFuK5JnC4mxG0W0AHbpk"
15
+ $env:GEMINI_API_KEY="AIzaSyCL-LxuBWFn54KBQ4v6ugeU0HPbfP2s0Ik"
16
+ $env:GEMINI_API_KEY="AIzaSyD_LZi79o8INH9MxrxTeB0x1RjLHDI59g0"
17
+ $env:GEMINI_API_KEY="AIzaSyAmxOSIHZ6P-ueiNXnAYl6KvV_DDHWc2MQ"
18
+
19
+ GG
20
+ $env:GEMINI_API_KEY="AIzaSyBF3PwtQwAJ3OtbjGZSllc7FeSCBV2w4Xs"
21
+ $env:GEMINI_API_KEY="AIzaSyA8Eo7Ju1g6xFZhNX46arhI13clJFGA18U"
22
+ $env:GEMINI_API_KEY="AIzaSyD8tk1msDRABtylCEhnzrduaFqczouIIfA"
23
+
24
+ AR
25
+ $env:GEMINI_API_KEY="AIzaSyBY24__F_VHc5MyAX2Q7fGEqjbwm9Y6fpQ"
26
+ $env:GEMINI_API_KEY="AIzaSyDmlimE9tXUXa30GaSjzwztkDKGmNXo3Jk"
27
+ $env:GEMINI_API_KEY="AIzaSyAKMhELnfTXMnka4VNcpjq81Ks38c9xQsw"
28
+
29
+ BM
30
+ $env:GEMINI_API_KEY="AIzaSyAUFp1MZ1cNds3U8XXlGzNWpShjAn8MI1E"
31
+ $env:GEMINI_API_KEY="AIzaSyCEW8YjAWqXIPct1TJ1hovTZ7jqOhBl4FM"
32
+
33
+ AM
34
+ $env:GEMINI_API_KEY="AIzaSyD10qhb9mP6DPq7xJStTSZsXy9Fbvi54kE"
35
+ $env:GEMINI_API_KEY="AIzaSyBFl2kWRd2smOd41GbJZTekL1yt7ZZkKw8"
36
+ $env:GEMINI_API_KEY="AIzaSyCdsPSBtXYuf18qOm8e9vORHPhEJslpRdI"
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "avatarciao",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs"
13
+ }