Skip to content

Commit

Permalink
Type fix for multicontroller
Browse files Browse the repository at this point in the history
  • Loading branch information
mzkrasner committed Apr 11, 2024
1 parent 98d3fde commit b7dc0b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions demo/server/src/controllers/multiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { getContext } from '../utils/context.js'
import { Request, Response, NextFunction } from 'express'
import { PointsWriter, PointsReader } from '@composexp/points'

type ContextAggregationContent = {
recipient: string
points: number
date: string
context: string
}

const getContextAggregation = async (req: Request, res: Response, next: NextFunction) => {
try {
const { ceramic, aggregationModelID } = await getContext()
Expand Down Expand Up @@ -55,7 +62,7 @@ const updateContextAggregation = async (req: Request, res: Response, next: NextF
const { amount, recipient, context } = req.body

//instantiate a writer and reader
const contextWriter = new PointsWriter({
const contextWriter = new PointsWriter<ContextAggregationContent>({
ceramic,
aggregationModelID,
})
Expand All @@ -73,7 +80,6 @@ const updateContextAggregation = async (req: Request, res: Response, next: NextF
recipient,
points: amount,
date: new Date().toISOString(),
//@ts-ignore
context,
})
res.locals = {
Expand All @@ -88,7 +94,6 @@ const updateContextAggregation = async (req: Request, res: Response, next: NextF
points: content ? content.points + amount : amount,
date: new Date().toISOString(),
recipient,
//@ts-ignore
context,
}
},
Expand Down
2 changes: 1 addition & 1 deletion demo/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const port = process.env.PORT || 8080;


const corsOptions = {
origin: ["http://localhost:3000", "https://developers.ceramic.network"],
origin: ["http://localhost:8080", "https://developers.ceramic.network"],
optionsSuccessStatus: 200 // For legacy browser support
}

Expand Down

0 comments on commit b7dc0b0

Please sign in to comment.