-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from SohamRatnaparkhi/next/api-setup
feat: all required api routes and their integrations
- Loading branch information
Showing
10 changed files
with
148 additions
and
43 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,19 @@ | ||
import axios from "axios"; | ||
import { NextResponse } from "next/server"; | ||
|
||
const getUserPhoneBook = async (route) => { | ||
try { | ||
const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; | ||
const userId = (route.url.split('/').reverse()[0]) | ||
console.log(backendURL + "/api/v1/phonebook/user/" + userId) | ||
const {data} = await axios.get(backendURL + "/api/v1/phonebook/user/" + userId); | ||
console.log(data) | ||
return NextResponse.json(data); | ||
} catch (error) { | ||
return NextResponse.error(error); | ||
} | ||
} | ||
|
||
export { | ||
getUserPhoneBook as GET | ||
} |
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
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,32 @@ | ||
import axios from "axios"; | ||
import { NextResponse } from "next/server"; | ||
|
||
const login = async (request) => { | ||
try { | ||
const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; | ||
const req = await request.json(); | ||
console.log(backendURL + "/api/v1/users/login") | ||
console.log(req) | ||
const {data} = await axios.post(backendURL + "/api/v1/users/login", req); | ||
console.log(data) | ||
return NextResponse.json(data); | ||
} catch (error) { | ||
return NextResponse.error(error); | ||
} | ||
} | ||
|
||
const register = async (request) => { | ||
try { | ||
const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; | ||
const req = await request.json(); | ||
const {data} = await axios.post(backendURL + "/api/v1/users/", req); | ||
return NextResponse.json(data); | ||
} catch (error) { | ||
return NextResponse.error(error); | ||
} | ||
} | ||
|
||
export { | ||
login as POST, | ||
register as PUT | ||
} |
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
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
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
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
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
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
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