762b3086 by RSA

fix

1 parent b57d268f
...@@ -209,3 +209,30 @@ ...@@ -209,3 +209,30 @@
209 .submit:hover { 209 .submit:hover {
210 background:#066d55; 210 background:#066d55;
211 } 211 }
212
213 .message .error_msg {
214 background: rgb(18 0 255 / 20%);
215 padding: 10px;
216 border-radius: 5px;
217 display: flex;
218 }
219
220 .message .error_msg span {
221 background: #0023ff;
222 width: 25px;
223 height: 25px;
224 display: inline-block;
225 text-align: center;
226 padding-top: 1px;
227 border-radius: 50px;
228 font-family: auto;
229 font-weight: 600;
230 vertical-align: top;
231 }
232
233 .message .error_msg .msg {
234 display: inline-block;
235 margin: 0 10px;
236 font-style: italic;
237 width: 80%;
238 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,6 +3,7 @@ const express = require('express') ...@@ -3,6 +3,7 @@ const express = require('express')
3 const bodyParser = require('body-parser') 3 const bodyParser = require('body-parser')
4 const cors = require('cors') 4 const cors = require('cors')
5 require('dotenv').config() 5 require('dotenv').config()
6 const rateLimit = require('express-rate-limit')
6 7
7 // Open AI Configuration 8 // Open AI Configuration
8 // console.log(process.env.OPENAI_API_ORG) 9 // console.log(process.env.OPENAI_API_ORG)
...@@ -12,6 +13,12 @@ const configuration = new Configuration({ ...@@ -12,6 +13,12 @@ const configuration = new Configuration({
12 }); 13 });
13 const openai = new OpenAIApi(configuration); 14 const openai = new OpenAIApi(configuration);
14 15
16 const rateLimiter = rateLimit({
17 windowMs: 1000 * 60 * 2, // 1 minute (refreshTime)
18 max: 10, // limit each IP to x requests per windowMs (refreshTime)
19 message: 'Sorry, too many requests. Please try again in a bit!',
20 });
21
15 // Express Configuration 22 // Express Configuration
16 const app = express() 23 const app = express()
17 const port = 3080 24 const port = 3080
...@@ -19,7 +26,7 @@ const port = 3080 ...@@ -19,7 +26,7 @@ const port = 3080
19 app.use(bodyParser.json()) 26 app.use(bodyParser.json())
20 app.use(cors()) 27 app.use(cors())
21 app.use(require('morgan')('dev')) 28 app.use(require('morgan')('dev'))
22 29 app.use(rateLimiter)
23 30
24 // Routing 31 // Routing
25 32
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 "cors": "^2.8.5", 13 "cors": "^2.8.5",
14 "dotenv": "^16.0.3", 14 "dotenv": "^16.0.3",
15 "express": "^4.18.2", 15 "express": "^4.18.2",
16 "express-rate-limit": "^6.7.0",
16 "morgan": "^1.10.0", 17 "morgan": "^1.10.0",
17 "openai": "^3.1.0" 18 "openai": "^3.1.0"
18 } 19 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!