Untitled

 avatar
unknown
plain_text
a year ago
5.0 kB
2
Indexable
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server, {
    cors: {
        origin: '*',
        methods: ['GET', 'POST']
    }
});
const cors = require('cors');

// Enable CORS for all origins for HTTP requests
app.use(cors());

app.get('/', (req, res) => {
    res.send('<h1>Hello world</h1>');
});

io.on('connection', (socket) => {
    console.log('a user connected');

    socket.on('face-moc-ws', () => {
        console.log('face-moc-ws request processing');

        const mockData = {
            'type': 1,
            'quality': 70,
            'image': '/9j/4AAQS...Oy0P/9k=',
            'verifyResponse': {
                'success': true,
                'code': '0',
                'message': 'SUCCESS',
                'data': 'IDVNM1870064389034187006438<<<28706124F2706122VNM<<<<<<<<<<<8VU<<NGUYET<LAN<<<<<<<<<<<<<<<<',
            },
            'icaoResponse': {
                'docNumber': '068977922',
                'name': 'PHUONG<DUNG<<<<<<<<<<< NGUYEN',
                'dateOfBirth': '730724',
                'validTo': '320121',
                'dateOfIssuance': null,
                'gender': 'MALE',
                'faceImage': '/9j/4A…aAP/Z',
                'dg13': {
                    'idCardNo': '420068977922',
                    'name': 'NGUYỄN PHƯƠNG DUNG',
                    'dateOfBirth': '24/07/1973',
                    'gender': 'Nam',
                    'nationality': 'Việt Nam',
                    'ethnic': 'Kinh',
                    'religion': 'Không',
                    'placeOfOrigin': 'Tràng Tiền, Hoàn Kiếm, Hà Nội',
                    'residenceAddress': 'Hà Hiệu, Ba Bể, Bắc Kạn',
                    'personalSpecificIdentification': 'Nốt ruồi c 1cm dưới sau đầu cánh mũi phải',
                    'dateOfIssuance': '18/11/2020',
                    'dateOfExpiry': '21/01/2032',
                    'motherName': null,
                    'fatherName': null,
                    'spouseName': null,
                    'oldIdCardNumber': '480766802',
                    'chipId': '0294DCACA1CF0000',
                },
                'fingerImages': [
                    {
                        'position': 7,
                        'image': '/9j/4A…aAP/Z',
                    },
                    {
                        'position': 2,
                        'image': '/9j/4A…aAP/Z',
                    },
                ],
            },
        };

        socket.emit('face-moc-ws-response', mockData);
    });

    socket.on('finger-moc-ws', () => {
        console.log('finger-moc-ws request processing');

        const mockData = {
            'type': 2,
            'quality': 70,
            'image': '/9j/4AAQS...Oy0P/9k=',
            'verifyResponse': {
                'success': true,
                'code': '0',
                'message': 'SUCCESS',
                'data': 'IDVNM1870064389034187006438<<<28706124F2706122VNM<<<<<<<<<<<8VU<<NGUYET<LAN<<<<<<<<<<<<<<<<',
            },
            'icaoResponse': {
                'docNumber': '068977922',
                'name': 'PHUONG<DUNG<<<<<<<<<<< NGUYEN',
                'dateOfBirth': '730724',
                'validTo': '320121',
                'dateOfIssuance': null,
                'gender': 'MALE',
                'faceImage': '/9j/4A…aAP/Z',
                'dg13': {
                    'idCardNo': '420068977922',
                    'name': 'NGUYỄN PHƯƠNG DUNG',
                    'dateOfBirth': '24/07/1973',
                    'gender': 'Nam',
                    'nationality': 'Việt Nam',
                    'ethnic': 'Kinh',
                    'religion': 'Không',
                    'placeOfOrigin': 'Tràng Tiền, Hoàn Kiếm, Hà Nội',
                    'residenceAddress': 'Hà Hiệu, Ba Bể, Bắc Kạn',
                    'personalSpecificIdentification': 'Nốt ruồi c 1cm dưới sau đầu cánh mũi phải',
                    'dateOfIssuance': '18/11/2020',
                    'dateOfExpiry': '21/01/2032',
                    'motherName': null,
                    'fatherName': null,
                    'spouseName': null,
                    'oldIdCardNumber': '480766802',
                    'chipId': '0294DCACA1CF0000',
                },
                'fingerImages': [
                    {
                        'position': 7,
                        'image': '/9j/4A…aAP/Z',
                    },
                    {
                        'position': 2,
                        'image': '/9j/4A…aAP/Z',
                    },
                ],
            },
        };

        socket.emit('finger-moc-ws-response', mockData);
    });

    socket.on('disconnect', () => {
        console.log('user disconnected');
    });
});



server.listen(1234, () => {
    console.log('listening on *:1234');
});
Editor is loading...
Leave a Comment