
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
cds-feature-toggle
Advanced tools
support feature toggle pattern for SAP CAP cds
// all event/entity/action/function require 'class-service' feature
@cds.features.required : ['class-service']
service ClassService {
// annotate the entity built-in events
@cds.features : [
{
on : 'DELETE',
required : 'feat-student-delete' // generally, maybe we dis-allowed user to delete entry
}
// other event will skip feature check
]
entity Students as projection on training.Student;
// or simply require feature for all events/action/function under the entity
@cds.features.required: 'feat-teacher-management'
entity Teachers as projection on training.Teacher;
// enabled by default
// if 'metricV2' or 'metricV3' is enabled,
// will prefer to trigger the redirect action
@cds.features.redirect.target : [metricV2]
action metric() returns MetricResponse;
// enabled when request context has the feature 'feature-metrics-v2'
@cds.features.required : 'feature-metrics-v2'
action metricV2() returns MetricResponse;
}
you need to enable the
cds-feature-toggle
bycds-hyper-app-service
extension config
npm i -S cds-hyper-app-service cds-feature-toggle
{
"cds": {
"requires": {
"app-service": {
"impl": "cds-hyper-app-service",
"exts": [
"builtIn",
{
"impl": "cds-feature-toggle",
"providers": [
{
"impl": "CDSRequestProvider",
"header": "x-cds-features"
}
]
}
]
}
}
}
}
cds-feature-toggle
provided a very simple provider which named CDSRequestProvider
, it will extract http header x-cds-features
as feature labels.
export class CDSRequestProvider implements FeatureProvider {
#headerName = HEADER_X_CDS_FEATURES_NAME;
/**
* extract http header as (enabled) feature list for current request
*
* @param options.featureHeaderName default is `x-cds-features`
*/
constructor(options: { featureHeaderName?: string }) {
if (typeof options?.featureHeaderName === "string") {
this.#headerName = options?.featureHeaderName;
}
}
public getFeatures(context: DetermineContext) {
// TODO: add signature verify
return Promise.resolve(context?.request?.get?.(this.#headerName)?.split(",") ?? []);
}
}
you can easily implement a feature provider by yourself, read feature from redis
or database
, it depends on you.
action
/function
@cds.features.required
on full entitycds-nats
KVaction
/function
will be little differenceFAQs
support feature toggle pattern for SAP CAP
The npm package cds-feature-toggle receives a total of 0 weekly downloads. As such, cds-feature-toggle popularity was classified as not popular.
We found that cds-feature-toggle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.