jblyberg / siptwo Goto Github PK
View Code? Open in Web Editor NEWA strongly-typed library for communicating with SIP2 servers
License: MIT License
A strongly-typed library for communicating with SIP2 servers
License: MIT License
Login Response message doesn't support checkSum
Dependency dateformat causing issue Error [ERR_REQUIRE_ESM]: require() of ES Module inside the module
node_modules\siptwo\dist\lib\helpers\DateTimeHelpers.js:4
const dateFormat = require("dateformat");
It seems there is an issue with item checkin. I have the following code in express
router.get('/checkin', async (req: Request, res: Response) => {
const item_barcode: string = `${req.query.item_barcode}`;
if (!item_barcode) {
return res.status(400).send("Item barcode is required");
}
const sipTwo = new SipTwo(sip2ConnectionOptions);
// sipTwo.setPatron({
// patronIdentifier: "123456",
// password: "demopass"
// });
try {
await sipTwo.login();
let datetime_now = new Date(); //getFormattedDated();
let checkinRequestDto: ICheckinRequestDto = {
location: sip2ConnectionOptions.institutionId,
offline: false,
returnDate: datetime_now,
itemIdentifier: item_barcode
};
const checkinResponse: ICheckinResponse = await sipTwo.requestCheckin(checkinRequestDto);
sipTwo.connection.close();
res.status(200).send(checkinResponse);
} catch (e) {
console.log(e);
sipTwo.connection.close();
res.status(500).send("Error: Internal Server Error");
}
});
There is no response from the server, ever.
However, if a non-existing item identifier is provided, then we get Invalid Item
response, which is expected.
I tested with the sip-testing-tool on the same sip server and was able to check-in the same item.
There could be an awaitable that is not being awaited and I have not been able to fix it. @jblyberg
I am testing out the new code release and have setup my project as follows but encounters the error mentioned.
`
import express, { Request, Response } from 'express';
import { SipTwo, ISip2ConnectionOptions, IPatronCredentials } from 'siptwo';
const app = express();
const PORT = 3000;
const sip2ConnectionOptions: ISip2ConnectionOptions = {
host: '172.20.22.876',
port: 6001,
username: 'DemoUser',
password: 'DemoUser22',
institutionId: 'CPL',
language: 'English',
timeout: 60,
maxListeners: 5,
};
const patronCredentials: IPatronCredentials = {
patronIdentifier: '123456',
password: 'DemoUser22',
institutionId: sip2ConnectionOptions.institutionId
};
const sipTwo = new SipTwo(sip2ConnectionOptions);
app.get('/', (req: Request, res: Response) => {
// Inside an async function/method
(async () => {
await sipTwo.login();
sipTwo.setPatron(patronCredentials);
const patronInfo = await sipTwo.requestPatronInformation();
console.log('patronInfo', patronInfo);
sipTwo.connection.close();
})();
res.send('Hello, TypeScript Express!');
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
`
Above code throws the error below
`
TypeError: Cannot read properties of undefined (reading 'sequence')
at new LoginRequest (C:\projects\siptwo\node_modules\siptwo\src\lib\requests\LoginRequest.ts:8:38)
at SipTwo.login (C:\projects\siptwo\node_modules\siptwo\src\lib\SipTwo.ts:71:26)
at C:\projects\siptwo\src\index.ts:29:22
at Generator.next ()
at C:\projects\siptwo\src\index.ts:8:71
at new Promise ()
at __awaiter (C:\projects\siptwo\src\index.ts:4:12)
at C:\projects\siptwo\src\index.ts:28:17
at C:\projects\siptwo\src\index.ts:35:7
at Layer.handle [as handle_request] (C:\projects\siptwo\node_modules\express\lib\router\layer.js:95:5)
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.