Commit e54f4eb1 authored by soheib's avatar soheib
Browse files

enable cors

parent df70e6f0
...@@ -531,10 +531,11 @@ export class AppService implements OnApplicationBootstrap { ...@@ -531,10 +531,11 @@ export class AppService implements OnApplicationBootstrap {
async getUserResult(username: string) { async getUserResult(username: string) {
let userRes = await this.resultModel.findOne({ username }) let userRes = await this.resultModel.findOne({ username })
let userIndexs = await this.lotoryResultModel.find({username})
let response: ResultResponse = new ResultResponse() let response: ResultResponse = new ResultResponse()
response.users = new Array<any>() response.users = new Array<any>()
response.lottory_chances_codes = new Array<string>()
userRes.pending_users.forEach(user => { userRes.pending_users.forEach(user => {
response.users.push({ userId: user, status: CommentStatus.notFollower }) response.users.push({ userId: user, status: CommentStatus.notFollower })
}) })
...@@ -550,10 +551,11 @@ export class AppService implements OnApplicationBootstrap { ...@@ -550,10 +551,11 @@ export class AppService implements OnApplicationBootstrap {
response.invalid_mentions = userRes.invalid_mentions, response.invalid_mentions = userRes.invalid_mentions,
response.pending_mentions = userRes.pending_mentions, response.pending_mentions = userRes.pending_mentions,
response.score = userRes.score response.score = userRes.score
userIndexs.forEach(index =>{
response.lottory_chances_codes.push(index.index.toString())
})
return { return {
response response
} }
} }
...@@ -622,6 +624,7 @@ export class ResultResponse { ...@@ -622,6 +624,7 @@ export class ResultResponse {
pending_mentions: number pending_mentions: number
score: number score: number
users?: Array<any> users?: Array<any>
lottory_chances_codes :Array<string>
} }
......
...@@ -4,5 +4,11 @@ import { AppModule } from './app.module'; ...@@ -4,5 +4,11 @@ import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
await app.listen(3000); await app.listen(3000);
app.enableCors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
})
} }
bootstrap(); bootstrap();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment