Skip to content

Commit

Permalink
[Update]: anime info api
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaBhattacharjee committed Sep 21, 2024
1 parent e3214ee commit cf2c70e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
NEXT_PUBLIC_MONGODB_URI =
NEXT_PUBLIC_JWT_TOKEN =
MONGODB_URI =
JWT_TOKEN =
# gemini api key
NEXT_PUBLIC_GEMINI_API_KEY =
# self host anime api url from https://github.com/consumet/api.consumet.org
NEXT_PUBLIC_ANIME_API_URL =
NEXT_PUBLIC_STREAM_API =
NEXT_PUBLIC_EMAIL_SERVICE = gmail
# email address
NEXT_PUBLIC_EMAIL =
Expand Down
6 changes: 3 additions & 3 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ COPY . .
EXPOSE 3000

CMD sh -c "\
if [ -z \"$NEXT_PUBLIC_MONGODB_URI\" ] || \
[ -z \"$NEXT_PUBLIC_JWT_TOKEN\" ] || \
if [ -z \"$MONGODB_URI\" ] || \
[ -z \"$JWT_TOKEN\" ] || \
[ -z \"$NEXT_PUBLIC_EMAIL\" ] || \
[-z \"$NEXT_PUBLIC_ANIME_API_URL"] || \
[ -z \"$NEXT_PUBLIC_EMAIL_PASSWORD\" ]; then \
echo \"Error: Required environment variables not set.\"; \
echo \"Please provide values for NEXT_PUBLIC_MONGODB_URI,NEXT_PUBLIC_ANIME_API_URL,NEXT_PUBLIC_JWT_TOKEN, NEXT_PUBLIC_EMAIL, and NEXT_PUBLIC_EMAIL_PASSWORD.\"; \
echo \"Please provide values for MONGODB_URI,NEXT_PUBLIC_ANIME_API_URL,JWT_TOKEN, NEXT_PUBLIC_EMAIL, and NEXT_PUBLIC_EMAIL_PASSWORD.\"; \
exit 1; \
fi; \
npm run dev"
2 changes: 1 addition & 1 deletion public/sw.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/app/api/login/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export async function POST(request: NextRequest) {
email: user.email,
};

const token = jwt.sign(tokenData, process.env.NEXT_PUBLIC_JWT_TOKEN!, { expiresIn: "2y" });
const token = jwt.sign(tokenData, process.env.JWT_TOKEN!, { expiresIn: "2y" });

const response = NextResponse.json({
message: "Login successful",
success: true,
});
response.cookies.set("token", token ,{
response.cookies.set("token", token, {
maxAge: 60 * 60 * 24 * 365 * 2,
});
return response;
Expand Down
2 changes: 1 addition & 1 deletion src/database/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mongoose from "mongoose";

export async function connect() {
try {
await mongoose.connect(process.env.NEXT_PUBLIC_MONGODB_URI || "mongodb://localhost:27017", {
await mongoose.connect(process.env.MONGODB_URI || "mongodb://localhost:27017", {
dbName: "Animetrix",
});
const connection = mongoose.connection;
Expand Down
2 changes: 1 addition & 1 deletion src/helper/jwtData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type DecodedToken = {
export const getDataFromJwt = (request: NextRequest): number => {
try {
const token = request.cookies.get("token")?.value || "";
const decodedToken: DecodedToken = jwt.verify(token, process.env.NEXT_PUBLIC_JWT_TOKEN!) as DecodedToken;
const decodedToken: DecodedToken = jwt.verify(token, process.env.JWT_TOKEN!) as DecodedToken;
return decodedToken.id;
} catch (error) {
throw new Error("Error decrypting jwt: " + error);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/animeapi/animetrixapi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const AnimeApi = `${process.env.NEXT_PUBLIC_ANIME_API_URL}/meta/anilist`;
export const AnifyApi = `https://api.anify.tv`;
export const AnifyApi = `https://anify.eltik.cc`;
export const StreamApi = `${process.env.NEXT_PUBLIC_STREAM_API}/api/v2`;

0 comments on commit cf2c70e

Please sign in to comment.