@dazejs/framework
Version:
Daze.js - A powerful web framework for Node.js
65 lines • 1.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cookie = void 0;
const container_1 = require("../../container");
class Cookie {
constructor(name, value, options = {}) {
this.app = container_1.Container.get('app');
this.name = name;
this.value = value;
this.options = Object.assign({}, this.app.get('config').get('cookie', {}), options);
}
getOptions() {
return this.options;
}
getName() {
return this.name;
}
getValue() {
return this.value;
}
setValue(val) {
if (val) {
this.value = val;
}
return this;
}
setHttpOnly(flag = true) {
this.options.httpOnly = flag;
return this;
}
setSigned(flag = true) {
this.options.signed = flag;
return this;
}
shouldSigned() {
this.setSigned(true);
return this;
}
doNotSigned() {
this.setSigned(false);
return this;
}
setMaxAge(expiry = 0) {
this.options.maxAge = expiry;
return this;
}
setDomain(pattern = '') {
this.options.domain = pattern;
return this;
}
setPath(uri = '/') {
this.options.path = uri;
return this;
}
setSecure(flag = false) {
this.options.secure = flag;
return this;
}
setExpires(expires) {
this.options.expires = expires;
return this;
}
}
exports.Cookie = Cookie;
//# sourceMappingURL=index.js.map