-
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.
email services send email and get all email controller & routes added
- Loading branch information
Showing
13 changed files
with
143 additions
and
10 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
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
packages/services/email/prisma/migrations/20240428182309_/migration.sql
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,13 @@ | ||
-- CreateTable | ||
CREATE TABLE "Email" ( | ||
"id" TEXT NOT NULL, | ||
"sender" TEXT NOT NULL DEFAULT '', | ||
"recipient" TEXT NOT NULL, | ||
"subject" TEXT NOT NULL, | ||
"body" TEXT NOT NULL, | ||
"source" TEXT NOT NULL DEFAULT '', | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Email_pkey" PRIMARY KEY ("id") | ||
); |
3 changes: 3 additions & 0 deletions
3
packages/services/email/prisma/migrations/migration_lock.toml
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,7 @@ | ||
import { Request, Response,NextFunction } from "express" | ||
|
||
const getEmail = async (req: Request, res: Response, next: NextFunction) => { | ||
|
||
} | ||
|
||
export default getEmail |
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 |
---|---|---|
@@ -1,4 +1,33 @@ | ||
import init from "./app"; | ||
import express from "express"; | ||
import dotenv from "dotenv"; | ||
import cors from "cors"; | ||
import morgan from "morgan"; | ||
import error = require("@/utils/error"); | ||
|
||
import router from "./routes"; | ||
|
||
init() | ||
dotenv.config(); | ||
|
||
const app = express(); | ||
app.use(express.json()); | ||
app.use(cors()); | ||
app.use(morgan("dev")); | ||
|
||
app.get("/health", (_req, res) => { | ||
res.status(200).json({ status: "UP" }); | ||
}); | ||
|
||
// routes | ||
|
||
app.use("/", router); | ||
|
||
// handler | ||
app.use(error.notFound); | ||
app.use(error.serverError); | ||
|
||
const port = process.env.PORT || 4000; | ||
const serviceName = process.env.SERVICE_NAME || "Email-Service"; | ||
|
||
app.listen(port, () => { | ||
console.log(`${serviceName} is running on port ${port}`); | ||
}); |
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,9 @@ | ||
import express from "express"; | ||
const router = express.Router(); | ||
import { getEmails, sendEmail } from '@/controllers' | ||
|
||
|
||
router.post('/emails/send', sendEmail) | ||
router.get('/emails', getEmails) | ||
|
||
export default router; |
Empty file.
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { z } from 'zod'; | ||
|
||
export const EmailCreateSchema = z.object({ | ||
recipient: z.string().email(), | ||
export const emailCreateSchema = z.object({ | ||
sender: z.string().optional(), | ||
recipient: z.string(), | ||
subject: z.string(), | ||
body: z.string(), | ||
source: z.string(), | ||
sender: z.string().email().optional(), | ||
source: z.string().optional() | ||
}); |
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
File renamed without changes.