Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
AWS_REGION: ${{ secrets.AWS_REGION }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_PHONE_NUMBER: ${{ secrets.TWILIO_PHONE_NUMBER }}
TWILIO_VIRTUAL_NUMBER: ${{ secrets.TWILIO_VIRTUAL_NUMBER }}
run: npm test
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
From node:22-alpine
FROM node:22-alpine

WORKDIR /usr/src/app

# Copy package files first
COPY package*.json ./
RUN npm install

COPY . .
# Clear any old dependencies and reinstall
RUN rm -rf node_modules && npm install

# Copy rest of the app source
COPY . .

# Copy env file (only if needed inside container)
COPY .env .env

# Generate Prisma client
RUN npx prisma generate

EXPOSE 3000
CMD ["npm", "run", "dev"]

CMD ["npm", "run", "dev"]
15 changes: 15 additions & 0 deletions __tests__/messaging.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import request from 'supertest'
import app from '../src/app'
import prisma from '../src/services/prisma'

test('POST /v1/location/:id/messaging/send-welcome sends a welcome message', async () => {
// First, create a location to use
const newLocation = await prisma.location.create({ data: { name: 'Messaging Test Location' } })

const res = await request(app)
.post(`/v1/location/${newLocation.id}/messaging/send-welcome`)
.send({ ticketNumber: '12345' })

expect(res.status).toBe(200)
expect(res.body).toHaveProperty('message', 'Welcome message sent successfully')
})
167 changes: 160 additions & 7 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"multer": "^2.0.2",
"multer-s3": "^3.0.1",
"pg": "^8.16.3",
"pino": "^8.19.0"
"pino": "^8.19.0",
"twilio": "^5.10.3"
},
"devDependencies": {
"@types/cors": "^2.8.17",
Expand All @@ -51,6 +52,7 @@
"@types/multer": "^2.0.0",
"@types/node": "^20.11.30",
"@types/supertest": "^6.0.3",
"@types/twilio": "^3.19.2",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"dotenv-cli": "^10.0.0",
Expand Down
17 changes: 12 additions & 5 deletions src/resources/locations/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ import locationController from './controller'
import entranceRouter from '../entrances/routes'
import employeeRouter from '../employee/routes'
import authRouter from '../auth/routes'
import messageRouter from '../messaging/routes'

const router = Router()

// define routes
router.route('/create').post(locationController.makeLocation)
router.delete('/:id', locationController.removeLocation)
// create and general routes
router.post('/create', locationController.makeLocation)
router.get('/', locationController.getLocations)
router.get('/:id', locationController.getSingleLocation)
router.put('/:id', locationController.updateLocation)

// 🔹 mount nested routers FIRST
router.use('/:locationId/messaging', messageRouter)
router.use('/:locationId/auth', authRouter)
router.use('/:locationId/employee', employeeRouter)
router.use('/:locationId/entrance', entranceRouter)

// 🔹 parameterized single routes AFTER nested ones
router.get('/:id', locationController.getSingleLocation)
router.put('/:id', locationController.updateLocation)
router.delete('/:id', locationController.removeLocation)

export default router
Loading