-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a274d26
Showing
61 changed files
with
2,202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/app/node_modules | ||
/app/.pnp | ||
/app/.pnp.js | ||
|
||
# testing | ||
/app/coverage | ||
|
||
# next.js | ||
/app/.next/ | ||
/app/out/ | ||
|
||
# production | ||
/app/build | ||
|
||
# misc | ||
/app/.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
/app/.env.local | ||
/app/.env.development.local | ||
/app/.env.test.local | ||
/app/.env.production.local | ||
|
||
# vercel | ||
/app/.vercel | ||
|
||
|
||
#BOT | ||
|
||
/bot/node_modules | ||
|
||
ecosystem.config.js | ||
docker-compose.yml | ||
docker-compose-ssl.yml | ||
stack.yml | ||
|
||
/app/package-lock.json | ||
/bot/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# By default all environment variables loaded through .env.local are only available in the Node.js environment, | ||
# meaning they won't be exposed to the browser. | ||
# In order to expose a variable to the browser you have to prefix the variable with NEXT_PUBLIC_. | ||
# https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser | ||
|
||
# Local variables | ||
ENV_LOCAL_HCAPTCHA_KEY="XXXXXXXXXXXXXXXXXXXXXX" | ||
ENV_LOCAL_HCAPTCHA_SECRET="XXXXXXXXXXXXXXXXXXXX" | ||
ENV_LOCAL_MONGODB_URI="" | ||
|
||
# Public variables | ||
NEXT_PUBLIC_ENV_LOCAL_VARIABLE="public_variable_from_env_local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# base image | ||
FROM node:alpine | ||
|
||
# create & set working directory | ||
RUN mkdir -p /usr/src | ||
WORKDIR /usr/src | ||
|
||
# copy source files | ||
COPY . /usr/src | ||
|
||
# install dependencies | ||
RUN npm install | ||
|
||
# start app | ||
RUN npm run build | ||
EXPOSE 8000 | ||
CMD npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import HCaptcha from '@hcaptcha/react-hcaptcha'; | ||
|
||
export default class HCaptchaWrapper extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { isMounted: false, ...props }; | ||
} | ||
|
||
componentDidMount() { this.setState({ isMounted: true }); } | ||
|
||
render() { | ||
if (!this.state.isMounted) return ''; | ||
return React.createElement(HCaptcha, this.state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import mongoose from 'mongoose' | ||
|
||
/* CaptchaSchema will correspond to a collection in your MongoDB database. */ | ||
const CaptchaSchema = new mongoose.Schema({ | ||
id: { type: String }, | ||
groupId: { type: String }, | ||
userId: { type: String }, | ||
status: { type: String }, | ||
}, { timestamps: true }) | ||
|
||
export default mongoose.models.Captcha || mongoose.model('Captcha', CaptchaSchema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import mongoose from 'mongoose' | ||
|
||
/* PetSchema will correspond to a collection in your MongoDB database. */ | ||
const PetSchema = new mongoose.Schema({ | ||
name: { | ||
/* The name of this pet */ | ||
|
||
type: String, | ||
required: [true, 'Please provide a name for this pet.'], | ||
maxlength: [20, 'Name cannot be more than 60 characters'], | ||
}, | ||
owner_name: { | ||
/* The owner of this pet */ | ||
|
||
type: String, | ||
required: [true, "Please provide the pet owner's name"], | ||
maxlength: [20, "Owner's Name cannot be more than 60 characters"], | ||
}, | ||
species: { | ||
/* The species of your pet */ | ||
|
||
type: String, | ||
required: [true, 'Please specify the species of your pet.'], | ||
maxlength: [30, 'Species specified cannot be more than 40 characters'], | ||
}, | ||
age: { | ||
/* Pet's age, if applicable */ | ||
|
||
type: Number, | ||
}, | ||
poddy_trained: { | ||
/* Boolean poddy_trained value, if applicable */ | ||
|
||
type: Boolean, | ||
}, | ||
diet: { | ||
/* List of dietary needs, if applicable */ | ||
|
||
type: Array, | ||
}, | ||
image_url: { | ||
/* Url to pet image */ | ||
|
||
required: [true, 'Please provide an image url for this pet.'], | ||
type: String, | ||
}, | ||
likes: { | ||
/* List of things your pet likes to do */ | ||
|
||
type: Array, | ||
}, | ||
dislikes: { | ||
/* List of things your pet does not like to do */ | ||
|
||
type: Array, | ||
}, | ||
}) | ||
|
||
export default mongoose.models.Pet || mongoose.model('Pet', PetSchema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "hcaptcha", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start -p 8000" | ||
}, | ||
"dependencies": { | ||
"@hcaptcha/react-hcaptcha": "^0.2.1", | ||
"amqplib": "^0.6.0", | ||
"autoprefixer": "^10.1.0", | ||
"mongoose": "^5.11.7", | ||
"next": "10.0.3", | ||
"postcss": "^8.2.1", | ||
"react": "17.0.1", | ||
"react-dom": "17.0.1", | ||
"swr": "^0.3.9", | ||
"tailwindcss": "^2.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import '../styles/globals.css' | ||
|
||
function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
} | ||
|
||
export default MyApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { notification } = require('../../utils/notification'); | ||
|
||
export default async (req, res) => { | ||
const { | ||
body: { chatId, userId, message }, | ||
method, | ||
} = req; | ||
|
||
// Nend notification message in group chat with RabbitMQ | ||
// Message should be related to user (by first_name) | ||
try { | ||
console.log('Send notification message:', message); | ||
notification(chatId, userId, message) | ||
res.statusCode = 200; | ||
res.json({ success: true, result: "Ok" }); | ||
} catch (error) { | ||
console.log(error); | ||
res.statusCode = 404; | ||
res.json({ success: false, result: error.message }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import dbConnect from "../../utils/dbConnect"; | ||
import Captcha from "../../models/Captcha"; | ||
|
||
export default async (req, res) => { | ||
const { | ||
body: { token, captcha }, | ||
method, | ||
} = req; | ||
|
||
console.log("token", token); | ||
|
||
try { | ||
let verifRes = await fetch( | ||
`https://hcaptcha.com/siteverify?response=${token}&secret=${process.env.ENV_LOCAL_HCAPTCHA_SECRET}`, | ||
{ | ||
method: "POST", | ||
} | ||
); | ||
|
||
verifRes = await verifRes.json(); | ||
console.log("verifRes", verifRes); | ||
|
||
if (process.env.NODE_ENV === "production" && !verifRes.success) { | ||
res.statusCode = 200; | ||
return res.json(verifRes); | ||
} | ||
|
||
// Update captcha.status = 'solved' on mongoDB | ||
await dbConnect(); | ||
captcha.status = "SOLVED"; | ||
const updCaptcha = await Captcha.findByIdAndUpdate(captcha._id, captcha, { | ||
new: true, | ||
runValidators: true, | ||
}); | ||
console.log(updCaptcha); | ||
res.statusCode = 200; | ||
res.json({ success: true, result: "Ok" }); | ||
} catch (error) { | ||
console.log(error); | ||
res.statusCode = 404; | ||
res.json({ success: false, result: error.message }); | ||
} | ||
}; |
Oops, something went wrong.