-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Yoginth
committed
Dec 4, 2024
1 parent
d4f6b19
commit 2146ef9
Showing
6 changed files
with
433 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 @@ | ||
dist |
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,38 @@ | ||
# Base image | ||
FROM node:18-alpine AS base | ||
RUN apk add --no-cache libc6-compat | ||
|
||
# Installer stage | ||
FROM base AS installer | ||
WORKDIR /app | ||
|
||
# Install pnpm globally | ||
RUN npm install -g pnpm | ||
|
||
# Copy all files to the build context | ||
COPY . . | ||
|
||
# Install dependencies | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Prune dev dependencies to reduce image size | ||
RUN pnpm prune --prod | ||
|
||
# Runner stage | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
# Install pnpm globally | ||
RUN npm install -g pnpm | ||
|
||
# Add non-root user for better security | ||
RUN addgroup --system --gid 1001 hey | ||
RUN adduser --system --uid 1001 app | ||
|
||
USER app | ||
|
||
# Copy built application and production dependencies from builder stage | ||
COPY --from=installer /app . | ||
|
||
# Command to run the app | ||
CMD sleep 3 && pnpm --filter @hey/cron 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,20 @@ | ||
{ | ||
"name": "@hey/invoice", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "AGPL-3.0", | ||
"scripts": { | ||
"generate": "NODE_ENV=production tsx src/index.ts", | ||
"typecheck": "tsc --pretty" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.4.5", | ||
"easyinvoice": "^3.0.47", | ||
"tsx": "^4.19.2" | ||
}, | ||
"devDependencies": { | ||
"@hey/config": "workspace:*", | ||
"@types/node": "^22.10.0", | ||
"typescript": "^5.7.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,49 @@ | ||
import easyinvoice, { type InvoiceData } from "easyinvoice"; | ||
|
||
const forYogi = true; | ||
const month = "1"; | ||
const year = "2024"; | ||
|
||
const amountPerAccount = 33.87; | ||
|
||
const data: InvoiceData = { | ||
apiKey: "PntktbOaJHXsR5272jJImlN5KW6RbXp0KL646ojBoM2SS5Set5Yh45pPPJ3DrON9", | ||
mode: "production", | ||
images: { logo: "https://hey-assets.b-cdn.net/images/app-icon/0.png" }, | ||
sender: { | ||
company: forYogi ? "Yoginth" : "Sagar", | ||
address: `HD-${forYogi ? "322" : "323"}, WeWork Latitude, 10th floor, RMZ Latitude Commercial, Bellary Road, Hebbal, Near Godrej Apt`, | ||
zip: "560024", | ||
city: "Bangalore, Karnataka", | ||
country: "India" | ||
}, | ||
translate: { number: "Invoice Number" }, | ||
products: [ | ||
{ description: "Hey Account", price: amountPerAccount, quantity: "1" } | ||
], | ||
bottomNotice: `GSTIN: ${forYogi ? "29AYKPY4219R1Z8" : "29JZXPS2474H1Z6"}`, | ||
settings: { | ||
currency: "INR", | ||
taxNotation: "GST", | ||
marginTop: 25, | ||
marginRight: 25, | ||
marginLeft: 25, | ||
marginBottom: 25 | ||
} | ||
}; | ||
|
||
const generateInvoice = () => { | ||
const dueDate = `${month}/${Math.floor(Math.random() * 30) + 1}/${year}`; | ||
|
||
const injectedData: InvoiceData = { | ||
...data, | ||
client: { company: "Client Corp" }, | ||
information: { number: "1", dueDate } | ||
}; | ||
|
||
easyinvoice.createInvoice(injectedData, (result) => { | ||
console.log("PDF base64 string: ", result.pdf); | ||
}); | ||
}; | ||
|
||
generateInvoice(); |
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,10 @@ | ||
{ | ||
"extends": "@hey/config/base.tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"noEmit": false, | ||
"outDir": "dist", | ||
"baseUrl": "." | ||
}, | ||
"include": ["**/*.ts", "src"] | ||
} |
Oops, something went wrong.