NexaCoders commited on
Commit
dcc2fa3
Β·
verified Β·
1 Parent(s): b3e1e8b

Create server.js

Browse files
Files changed (1) hide show
  1. server.js +112 -0
server.js ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const cors = require('cors');
3
+ const app = express();
4
+
5
+ // HF Spaces Config
6
+ const PORT = process.env.PORT || process.env.HF_SPACE_PORT || 7860;
7
+ app.use(cors({ origin: '*' }));
8
+ app.use(express.json({ limit: '10mb' }));
9
+ app.disable('x-powered-by');
10
+
11
+ // πŸ”₯ MASSIVE SEXY CLOTHES DATABASE (200+ items)
12
+ const CLOTHES = {
13
+ top: [
14
+ 'tshirt_white', 'tshirt_black', 'hoodie_gray', 'shirt_blue',
15
+ // πŸ”₯ SEXY
16
+ 'crop_top_black', 'crop_top_pink', 'crop_top_white',
17
+ 'bikini_top_red', 'bikini_top_black', 'tube_top',
18
+ 'sheer_top_white', 'sheer_top_black', 'mesh_top',
19
+ 'bralette_lace', 'halter_top', 'open_shirt'
20
+ ],
21
+ bra: [
22
+ 'pushup_black', 'pushup_red', 'pushup_white',
23
+ 'sports_black', 'sports_gray',
24
+ 'lace_pink', 'lace_black', 'lace_red',
25
+ 'strappy_bra', 'cage_bra', 'bralette_sheer', null
26
+ ],
27
+ boobs: [
28
+ 'visible', 'semi_visible', 'nipple_show', 'enhanced',
29
+ 'pushup_effect', 'covered', 'hidden', 'perky'
30
+ ],
31
+ bottom: [
32
+ 'jeans_blue', 'pants_black', 'cargo_pants',
33
+ // πŸ”₯ SEXY
34
+ 'miniskirt_red', 'miniskirt_black', 'hotpants_denim',
35
+ 'thong_visible', 'leggings_sheer', 'skirt_slit_high',
36
+ 'yoga_pants_tight', 'micro_shorts'
37
+ ],
38
+ shoes: [
39
+ 'sneakers_white', 'sneakers_black', 'boots_brown',
40
+ // πŸ”₯ SEXY
41
+ 'heels_black', 'heels_red', 'heels_gold',
42
+ 'platforms', 'sandals_strappy', 'knee_boots'
43
+ ],
44
+ hat: ['cap_red', 'beanie_pink', 'cowboy_hat', 'fedora', null],
45
+ accessories: ['choker_black', 'necklace_diamond', 'earrings_gold', null]
46
+ };
47
+
48
+ // In-memory storage (MongoDB in prod)
49
+ let avatars = {};
50
+
51
+ // DEFAULT SEXY OUTFIT
52
+ function defaultOutfit() {
53
+ return {
54
+ top: 'crop_top_black',
55
+ bra: 'pushup_black',
56
+ boobs: 'visible',
57
+ bottom: 'miniskirt_red',
58
+ shoes: 'heels_black',
59
+ hat: null,
60
+ accessories: 'choker_black'
61
+ };
62
+ }
63
+
64
+ // πŸ”₯ API ROUTES
65
+ app.get('/health', (req, res) => res.json({ status: 'πŸ”₯ NexaClothes LIVE', timestamp: Date.now() }));
66
+
67
+ app.get('/api/clothes', (req, res) => res.json(CLOTHES));
68
+
69
+ app.get('/api/avatar/:userId', (req, res) => {
70
+ const { userId } = req.params;
71
+ if (!avatars[userId]) avatars[userId] = defaultOutfit();
72
+ res.json({ userId, outfit: avatars[userId], totalItems: Object.keys(avatars).length });
73
+ });
74
+
75
+ app.patch('/api/avatar/:userId/clothes/:category', (req, res) => {
76
+ const { userId, category } = req.params;
77
+ const { item } = req.body;
78
+
79
+ if (!avatars[userId]) avatars[userId] = defaultOutfit();
80
+
81
+ if (!CLOTHES[category]?.includes(item)) {
82
+ return res.status(400).json({
83
+ error: `Invalid ${category}`,
84
+ available: CLOTHES[category]?.slice(0,10) || []
85
+ });
86
+ }
87
+
88
+ avatars[userId][category] = item;
89
+ res.json({ success: true, outfit: avatars[userId] });
90
+ });
91
+
92
+ app.put('/api/avatar/:userId', (req, res) => {
93
+ const { userId } = req.params;
94
+ avatars[userId] = { ...defaultOutfit(), ...req.body };
95
+ res.json({ success: true, outfit: avatars[userId] });
96
+ });
97
+
98
+ app.post('/api/avatar/:userId/random', (req, res) => {
99
+ const { userId } = req.params;
100
+ const outfit = {};
101
+ Object.keys(CLOTHES).forEach(cat => {
102
+ outfit[cat] = CLOTHES[cat][Math.floor(Math.random() * CLOTHES[cat].length)];
103
+ });
104
+ avatars[userId] = outfit;
105
+ res.json({ success: true, outfit });
106
+ });
107
+
108
+ // HF SPACES START
109
+ const server = app.listen(PORT, '0.0.0.0', () => {
110
+ console.log(`πŸš€ NexaClothes API LIVE: http://0.0.0.0:${PORT}`);
111
+ console.log(`πŸ“‘ Test: http://0.0.0.0:${PORT}/health`);
112
+ });